Skip to content

Commit d1bbe8b

Browse files
paulmeierclaude
andcommitted
fix(oidc): redirect callback to /login so the SPA receives oidc_code
After a successful OIDC callback the backend redirected the browser to `{frontend_url}/?oidc_code=…` (the site root). But the SvelteKit SPA only reads `oidc_code` on the `/login` route: the root route immediately `goto`s `/files`, and the layout's auth guard bounces an unauthenticated visitor to `/login?redirect=…` — both of which drop the `oidc_code` query param. The exchange step (`POST /api/auth/oidc/exchange`) therefore never runs, so the user lands back on the login form with no session even though the IdP round-trip and callback succeeded. Redirect to `{frontend_url}/login?oidc_code=…` instead — the route that actually performs the exchange. `/login` is public, so the guard doesn't interfere; after a successful exchange the page navigates on to the app. This was masked until now by #510 (the duplicate-callback 403 always fired first); with that fixed, the callback reaches the frontend and this second bug surfaces. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e7b85e5 commit d1bbe8b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/interfaces/api/handlers/auth_handler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ pub async fn oidc_authorize(
886886
/// Handle the OIDC provider callback.
887887
///
888888
/// Validates the `state` / PKCE / nonce, exchanges the code for tokens, then
889-
/// redirects the browser to the frontend with a short-lived exchange code
890-
/// (`/?oidc_code=…`).
889+
/// redirects the browser to the frontend login route with a short-lived
890+
/// exchange code (`/login?oidc_code=…`), which the SPA swaps for a session.
891891
#[utoipa::path(
892892
get,
893893
path = "/api/auth/oidc/callback",
@@ -937,7 +937,7 @@ pub async fn oidc_callback(
937937
// Regular web login, redirect to frontend with exchange code
938938
let config = auth_app.oidc_config().unwrap();
939939
let frontend_url = config.frontend_url.trim_end_matches('/');
940-
let redirect_url = format!("{}/?oidc_code={}", frontend_url, exchange_code);
940+
let redirect_url = format!("{}/login?oidc_code={}", frontend_url, exchange_code);
941941
tracing::info!("OIDC login successful, redirecting with exchange code");
942942
Ok(Redirect::temporary(&redirect_url))
943943
}

0 commit comments

Comments
 (0)