Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
7a65553
add 2024 sponsor logos
JoshCLim Jun 11, 2024
87691b1
add tailwind prettier plugin
JoshCLim Jun 14, 2024
d89aba4
update eslint-plugin-prettier to compatible version
JoshCLim Jun 14, 2024
e268005
format and lint code
JoshCLim Jun 14, 2024
67b9d54
update eslint config
JoshCLim Jun 14, 2024
c8be69d
feat: add 2024 sponsor logos (#488)
JoshCLim Jun 15, 2024
93c085f
remove grouped tailwind psuedo-classes
JoshCLim Jun 16, 2024
9f116e4
refactor(frontend): remove MUI theme and CSS baseline
JoshCLim Jun 16, 2024
a20223c
resolve merge conflict from sponsor logos
JoshCLim Jun 16, 2024
c91aa3d
format tailwind classes
JoshCLim Jun 16, 2024
3da7c3b
Merge branch 'main' into CHAOS-489-update-eslint-prettier-config
JoshCLim Jun 16, 2024
4ae417f
set prettier config options
JoshCLim Jun 16, 2024
f38688c
format according to prettier config
JoshCLim Jun 16, 2024
1c88a7b
Merge branch 'CHAOS-489-update-eslint-prettier-config' into CHAOS-491…
JoshCLim Jun 16, 2024
6b818da
format tw macros via Tailwind functions config
JoshCLim Jun 16, 2024
71e7655
Merge branch 'CHAOS-489-update-eslint-prettier-config' into CHAOS-491…
JoshCLim Jun 16, 2024
484adc2
AdminSideBar styles and width state rewritten
JoshCLim Jun 16, 2024
afb2b4c
feat(AdminSidebar): migrate admin sidebar from MUI to Radix UI Primit…
JoshCLim Jun 16, 2024
886ac12
feat(CampaignCreationPreview): migrate from MUI and remove bad Campai…
JoshCLim Jun 17, 2024
1d61492
feat(AdminSidebar): add borders between organisations
JoshCLim Jun 17, 2024
e0f8690
refactor(BackgroundWrapper): delete unused component
JoshCLim Jun 18, 2024
5f822ce
feat(ApplicationPreviewer): migrate ApplicationPreviewer away from MUI
JoshCLim Jun 18, 2024
6c5c1f4
feat(CreateOrganisationForm): rewrite components using Tailwind
JoshCLim Jun 25, 2024
6792d86
feat(Dropdown): remove unused imports
JoshCLim Jun 25, 2024
fbeb636
more migration
JoshCLim Jul 18, 2024
c107963
feat(frontend): update login/signup buttons to Coming Soon (#499)
JoshCLim Jul 19, 2024
2ea1a7a
feat(Signup): migrate to twin
JoshCLim Aug 3, 2024
4f8aafe
feat(frontend): Update ESLint and Prettier config (#490)
JoshCLim Oct 7, 2024
5db09ad
email sending
KavikaPalletenne Dec 2, 2024
5a163d3
fix "recipient" spelling
KavikaPalletenne Dec 2, 2024
07680cc
cargo fmt
KavikaPalletenne Dec 2, 2024
7c3d624
fix errors with `template_subject` introduction
KavikaPalletenne Dec 2, 2024
5aeeb2f
cargo clippy fixes
KavikaPalletenne Dec 2, 2024
706f814
application role preferences and updating applied roles
KavikaPalletenne Dec 2, 2024
299ee9b
lock out user from application changes after submission
KavikaPalletenne Dec 2, 2024
43e47cd
lock application after submission and campaign close date
KavikaPalletenne Dec 2, 2024
80c1abe
fix uses of `LEFT JOIN` when `JOIN` was needed
KavikaPalletenne Dec 2, 2024
efe6c00
make unsubmitted application viewable after campaign end
KavikaPalletenne Dec 2, 2024
02b705b
only submitted applications are viewable by reviewers
KavikaPalletenne Dec 2, 2024
6fcb06a
added `Answer`-related schemas to api.yaml
KavikaPalletenne Dec 2, 2024
c08e4b4
register new `ApplicationHandler` endpoints in app
KavikaPalletenne Dec 3, 2024
d2d402a
completed up to /organisation/slug_check
KavikaPalletenne Dec 3, 2024
b2b7426
`NewCampaign` model for campaign create request body
KavikaPalletenne Dec 3, 2024
0e17bdb
block applications for ended campaigns
KavikaPalletenne Dec 3, 2024
36fd5c1
`NewEmailTemplate` model for template request body
KavikaPalletenne Dec 3, 2024
43eee89
fix `assert_campaign_is_open()` naming
KavikaPalletenne Dec 3, 2024
266fbff
api.yaml up to `/organisation/{id}/logo`
KavikaPalletenne Dec 3, 2024
049a393
update `api.json` up to `/organisation/{id}/logo`
KavikaPalletenne Dec 3, 2024
eab3dba
Merge branch 'backend-main' into new-main
gyoumi Dec 17, 2024
a6c7cfd
rerouted application page to new backend and made prop error fixes fo…
gyoumi Dec 22, 2024
31a6bcc
rerouted application page to new backend
gyoumi Dec 22, 2024
2799c1f
merge mui migration pr
gyoumi Dec 22, 2024
1bdc199
fixed all initial errors
gyoumi Dec 22, 2024
38c25fe
fixed all initial errors
gyoumi Dec 22, 2024
af16cac
Move some `Rating` handler fn to `ApplicationHandler`
KavikaPalletenne Dec 31, 2024
6b18074
update `api.json` up to `/rating/{id}`
KavikaPalletenne Dec 31, 2024
694d813
saving for now
gyoumi Jan 14, 2025
611edc6
Merge branch 'backend-main' into new-main
gyoumi Jan 14, 2025
880c100
created user context
gyoumi Apr 20, 2025
94007d2
created user context + preparing for work division
gyoumi Apr 20, 2025
66e794b
feat: implemented cookie wrapped auth token
May 17, 2025
166d2f2
fix: SQL sub query alias
May 17, 2025
63b48e2
saving prompt updates
gyoumi Jun 13, 2025
cad37d1
merged
gyoumi Jun 13, 2025
935b9bc
more prompts
gyoumi Jun 13, 2025
861a1ce
Merge branch 'CHAOS-542-Auth-Token-Set-Cookie' into vibecode-test
gyoumi Jun 13, 2025
b5274fb
fixed merge
gyoumi Jun 13, 2025
2c44ea2
login working
gyoumi Jul 29, 2025
b5e2cee
only comming fe changes
gyoumi Jul 29, 2025
2a5f81d
Merge branch 'CHAOS-224-KHAOS-rewrite' into vibecode-test
gyoumi Jul 29, 2025
da41670
Merge branch 'CHAOS-224-KHAOS-rewrite' into vibecode-test
gyoumi Jul 29, 2025
a3f1bb9
saving state for now
gyoumi Jul 29, 2025
16e3bbb
idk why this didnt merge
gyoumi Jul 29, 2025
43285a8
idk why this didnt merge either
gyoumi Jul 29, 2025
9167f80
got dashboard working kind of lol
gyoumi Jul 29, 2025
091e18f
Merge branch 'CHAOS-224-KHAOS-rewrite' into vibecode-test
gyoumi Jul 31, 2025
9ca0be7
fixed frontend admin org route
gyoumi Aug 1, 2025
95cfb24
fixed frontend admin org route
gyoumi Aug 1, 2025
97a2107
Merge branch 'CHAOS-224-KHAOS-rewrite' into CHAOS-543-fe-auth-refactor
KavikaPalletenne Aug 1, 2025
9b2b510
fixed readme conflict
gyoumi Aug 1, 2025
54521cf
Merge branch 'CHAOS-543-fe-auth-refactor' of github.com:devsoc-unsw/c…
gyoumi Aug 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ target
Cargo.lock
prisma-cli/prisma/migrations
/.idea
**/.DS_Store
**/.DS_Store
.env.*
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ Request -> Middleware (optional) -> Handler -> Service -> Middleware (Optional)
- JWT

### Storage
- Object storage
- Object storage
4 changes: 4 additions & 0 deletions backend/migrations/20240406023149_create_users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ CREATE TABLE users (
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- Seed initial superuser
INSERT INTO users (id, email, name, role)
VALUES (10000, 'chaosdirectors@devsoc.app', 'Super Admin', 'SuperUser');

CREATE UNIQUE INDEX IDX_users_email_lower on users((lower(email)));
81 changes: 71 additions & 10 deletions backend/server/src/handler/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,52 @@ use crate::service::auth::create_or_get_user_id;
use crate::service::jwt::encode_auth_token;
use axum::extract::{Query, State};
use axum_extra::extract::cookie::{Cookie, CookieJar, Expiration};
use axum::response::IntoResponse;
use axum::response::{IntoResponse, Redirect};
use oauth2::reqwest::async_http_client;
use oauth2::{AuthorizationCode, TokenResponse};
use oauth2::{AuthorizationCode, TokenResponse, Scope};
use time::OffsetDateTime;

/// Handles the Google OAuth2 callback.
///
/// This handler processes the OAuth2 code received from Google after user authorization.
/// It exchanges the code for an access token, retrieves the user's profile information,
/// creates or retrieves the user in the database, and generates a JWT token for authentication.
///
/// # Arguments
///
/// * `state` - The application state
/// * `query` - The OAuth2 callback query parameters containing the authorization code
/// * `oauth_client` - The OAuth2 client for Google authentication
///
/// # Returns
///
/// * `Result<impl IntoResponse, ChaosError>` - JWT token or error
///
/// Initiates the Google OAuth2 flow.
///
/// This handler redirects users to Google's OAuth2 authorization URL to begin
/// the authentication process.
///
/// # Arguments
///
/// * `state` - The application state containing the OAuth2 client
///
/// # Returns
///
/// * `Result<impl IntoResponse, ChaosError>` - Redirect to Google OAuth or error
pub async fn google_auth_init(
State(state): State<AppState>,
) -> Result<impl IntoResponse, ChaosError> {
let (auth_url, _csrf_token) = state.oauth2_client
.authorize_url(|| oauth2::CsrfToken::new_random())
.add_scope(Scope::new("openid".to_string()))
.add_scope(Scope::new("email".to_string()))
.add_scope(Scope::new("profile".to_string()))
.url();

Ok(Redirect::to(auth_url.as_str()))
}

/// Handles the Google OAuth2 callback.
///
/// This handler processes the OAuth2 code received from Google after user authorization.
Expand Down Expand Up @@ -75,8 +116,16 @@ pub async fn google_callback(
.expires(Expiration::DateTime(OffsetDateTime::now_utc() + time::Duration::days(5))) // Set an expiration time of 5 days, TODO: read from env?
.secure(!state.is_dev_env) // Send only over HTTPS, comment out for testing
.path("/"); // Available for all paths
// Add the cookie to the response
Ok(jar.add(cookie))

// Redirect to the frontend dashboard after successful authentication
let redirect_url = if state.is_dev_env {
"http://localhost:3000/dashboard"
} else {
"/dashboard" // In production, this would be the full URL
};

// Add the cookie and redirect
Ok((jar.add(cookie), Redirect::to(redirect_url)))
}

pub struct DevLoginHandler;
Expand Down Expand Up @@ -104,8 +153,12 @@ impl DevLoginHandler {
.http_only(true) // Prevent JavaScript access
.expires(Expiration::DateTime(OffsetDateTime::now_utc() + time::Duration::days(5))) // Set an expiration time of 5 days, TODO: read from env?
.path("/"); // Available for all paths
// Add the cookie to the response
Ok(jar.add(cookie))

// Redirect to the frontend dashboard after successful authentication
let redirect_url = "http://localhost:3000/dashboard";

// Add the cookie and redirect
Ok((jar.add(cookie), Redirect::to(redirect_url)))
}

pub async fn dev_org_admin_login(
Expand All @@ -130,8 +183,12 @@ impl DevLoginHandler {
.http_only(true) // Prevent JavaScript access
.expires(Expiration::DateTime(OffsetDateTime::now_utc() + time::Duration::days(5))) // Set an expiration time of 5 days, TODO: read from env?
.path("/"); // Available for all paths
// Add the cookie to the response
Ok(jar.add(cookie))

// Redirect to the frontend dashboard after successful authentication
let redirect_url = "http://localhost:3000/dashboard";

// Add the cookie and redirect
Ok((jar.add(cookie), Redirect::to(redirect_url)))
}

pub async fn dev_user_login(
Expand All @@ -156,7 +213,11 @@ impl DevLoginHandler {
.http_only(true) // Prevent JavaScript access
.expires(Expiration::DateTime(OffsetDateTime::now_utc() + time::Duration::days(5))) // Set an expiration time of 5 days, TODO: read from env?
.path("/"); // Available for all paths
// Add the cookie to the response
Ok(jar.add(cookie))

// Redirect to the frontend dashboard after successful authentication
let redirect_url = "http://localhost:3000/dashboard";

// Add the cookie and redirect
Ok((jar.add(cookie), Redirect::to(redirect_url)))
}
}
4 changes: 2 additions & 2 deletions backend/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async fn main() -> Result<(), ChaosError> {
dotenvy::dotenv()?;

let app = app().await?;
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
axum::serve(listener, app).await.unwrap();

Ok(())
}
}
4 changes: 3 additions & 1 deletion backend/server/src/models/app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::handler::answer::AnswerHandler;
use crate::handler::application::ApplicationHandler;
use crate::handler::auth::{google_callback, DevLoginHandler};
use crate::handler::auth::{google_callback, google_auth_init, DevLoginHandler};
use crate::handler::campaign::CampaignHandler;
use crate::handler::email_template::EmailTemplateHandler;
use crate::handler::offer::OfferHandler;
Expand Down Expand Up @@ -123,6 +123,7 @@ pub async fn app() -> Result<Router, ChaosError> {
.allow_credentials(true)
.allow_origin([
"http://localhost".parse().unwrap(),
"http://localhost:3000".parse().unwrap(),
"https://chaos.devsoc.app".parse().unwrap(),
"http://chaos.devsoc.app".parse().unwrap(),
"https://chaosstaging.devsoc.app".parse().unwrap(),
Expand All @@ -131,6 +132,7 @@ pub async fn app() -> Result<Router, ChaosError> {

Ok(Router::new()
.route("/", get(|| async { "Join DevSoc! https://devsoc.app/" }))
.route("/auth/google", get(google_auth_init))
.route("/api/auth/callback/google", get(google_callback))
.route("/api/v1/dev/super_admin_login", get(DevLoginHandler::dev_super_admin_login))
.route("/api/v1/dev/org_admin_login", get(DevLoginHandler::dev_org_admin_login))
Expand Down
19 changes: 16 additions & 3 deletions backend/server/src/service/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,28 @@ pub async fn extract_user_id_from_request(
) -> Result<i64, ChaosError> {
let decoding_key = &state.decoding_key;
let jwt_validator = &state.jwt_validator;


let TypedHeader(cookies) = parts
.extract::<TypedHeader<Cookie>>()
.await
.map_err(|_| ChaosError::NotLoggedIn)?;
.map_err(|e| {
ChaosError::NotLoggedIn
})?;

let token = cookies.get("auth_token").ok_or(ChaosError::NotLoggedIn)?;


let token = cookies.get("auth_token").ok_or_else(|| {
ChaosError::NotLoggedIn
})?;



let claims =
decode_auth_token(token, decoding_key, jwt_validator).ok_or(ChaosError::NotLoggedIn)?;
decode_auth_token(token, decoding_key, jwt_validator).ok_or_else(|| {
ChaosError::NotLoggedIn
})?;


Ok(claims.sub)
}
4 changes: 2 additions & 2 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VITE_OAUTH_CALLBACK_URL=https://accounts.google.com/o/oauth2/v2/auth?client_id=985448402284-al4vuqpokkhgv6h952lhu6iasg1lupug.apps.googleusercontent.com&redirect_uri=http://localhost:3000/auth/callback&response_type=code&scope=profile email&access_type=online
VITE_API_BASE_URL=http://localhost:8000
VITE_OAUTH_CALLBACK_URL=https://accounts.google.com/o/oauth2/v2/auth?client_id=731862014126-5b109p4v6b173910ib347gtfn0ecnacj.apps.googleusercontent.com&redirect_uri=http://localhost:8080/api/auth/callback/google&response_type=code&scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile&access_type=offline
VITE_API_BASE_URL=http://localhost:8080
BROWSER=none
2 changes: 1 addition & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": "./tsconfig.json"
"project": "./frontend/tsconfig.json"
},
"plugins": ["react", "prettier"],
"rules": {
Expand Down
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env.development
.env
1 change: 1 addition & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
content="iVGfVNkqvkNxy6yl6RKaGIok_5_DOndLxzj9ydHWJrA"
/>
<meta name="description" content="CSESoc Hiring Web App" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' http://localhost:8080 https://accounts.google.com https://openidconnect.googleapis.com;" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand Down
Loading
Loading