Commit Graph

4 Commits

Author SHA1 Message Date
Bastian Wagner
1d2467049d feat: fully backend-driven OIDC session flow (session cookie, not bearer token)
Replace the hybrid flow (frontend PKCE + POST /auth/session token
exchange, access token in sessionStorage) with a classic backend-driven
BFF: the browser only ever navigates to GET /api/v1/auth/login and is
redirected straight to the IdP; PKCE verifier/state live server-side in
Redis (SessionStoreService); GET /api/v1/auth/callback (now the
registered IdP redirect URI, replacing the frontend's /auth/callback
route, which is deleted) verifies the id_token, JIT-provisions the
user, creates a Redis-backed session, and sets one httpOnly SameSite=Lax
cookie before redirecting into the app. No token material of any kind
ever reaches the browser.

OidcAuthGuard (per-request bearer JWT verification) is replaced by
SessionAuthGuard (cookie -> Redis session lookup) across every
controller that used it. cookie-parser is now wired into main.ts.

Frontend AuthService shrinks to login()/logout()/ensureSessionChecked();
pkce.ts, auth.interceptor.ts, and the callback component/route are all
removed as dead code under this model.

New required env var: APP_BASE_URL (source of truth for the OIDC
redirect_uri and the post-login redirect target).

Verified end-to-end against the real API, Redis, and a mocked IdP:
login redirect shape, callback cookie + redirect, state-replay
rejection, /users/me 401<->200 around the cookie, and logout.
2026-08-17 17:33:55 +02:00
Bastian Wagner
981cecbcbd feat: switch oidc client to confidential (backend token exchange)
The provisioned IdP client (https://auth.forgecore.work) is confidential
rather than public/PKCE-only, so a client secret must never reach the
browser. The frontend now only performs the Authorization Code + PKCE
redirect itself (hand-rolled PKCE, oidc-client-ts dependency removed)
and hands the resulting code + verifier to a new, intentionally
unauthenticated POST /api/v1/auth/session endpoint, which performs the
code-for-tokens exchange server-side using OIDC_CLIENT_SECRET and
returns only {accessToken, expiresIn} — refresh_token/id_token are
never forwarded to the client.

New required backend env vars: OIDC_CLIENT_ID, OIDC_CLIENT_SECRET.
Added frontend/proxy.conf.json so the Angular dev server forwards
/api and /health to the local API without needing CORS.
2026-08-17 16:36:49 +02:00
Bastian Wagner
854df5bb2d fix: export guard dependencies so cross-module @UseGuards resolves
NestJS resolves a guard referenced via @UseGuards(SomeGuard) using the
consuming module's injector, not the guard's own declaring module's
injector. OidcAuthGuard and TripMembershipGuard are shared across
several feature modules, so every constructor dependency they need
(UsersRepository/UsersService, TripMembersRepository, etc.) must be
re-exported by AuthModule/TripsLibModule/UsersLibModule, not just the
guard classes themselves. Found via the Phase 02 end-to-end smoke test
against a mocked IdP, which failed to boot the API before this fix.
2026-08-17 16:10:27 +02:00
Bastian Wagner
5abc7cbe29 feat: verify oidc bearer tokens and jit-provision users 2026-08-17 14:54:42 +02:00