fix(auth): fetch a fresh id token hint at sign-out #410
Inga granskare
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
priority
high
priority
low
priority
medium
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-web!410
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "fix/398-signout-confirm"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
Closes #398.
Cause
The portal stored the login id token in
gb_id_tokenfor 8 hours and sent it asid_token_hintat sign-out. Itssidnames the Keycloak SSO session from portal login. Keycloak's default SSO idle timeout is 30 minutes, so that session often ends while the portal session lives on. A later sign-in elsewhere (for example on Forgejo) starts a new SSO session. Keycloak's end-session endpoint then sees a hint for one session and a browser cookie for another, and shows "Do you want to log out?".#404 dropped hints from another issuer or client. It could not catch a stale
sid, because the portal cannot see the browser's Keycloak session.Change
POST /auth/logoutclears the portal session, then starts a silentprompt=noneauthorization round trip.gb_oidc_logouttransaction cookie holdslogout:<state>./auth/callbacktakes the sign-out branch only when it matches the returned state (constant-time). A sign-out in another tab cannot turn an in-flight login into a sign-out.error=login_required: no Keycloak session left, go home.verifyIdTokenand the nonce check. The token comes straight from the token endpoint, is PKCE-bound and is used only as an end-session hint. Noted indocs/design/oidc-security-review.md.login.tstosrc/lib/auth/authorize.ts, shared by login and sign-out.gb_id_tokencookie is no longer set. Sign-out still deletes it for older browsers.idTokenMatchesandsetIdTokenHintare removed.Tests
src/test/logout.test.tscovers the silent round trip start, the callback with a fresh hint,login_required, a failed token exchange, a forged state, and a sign-out flag left by another tab.src/lib/auth/authorize.test.tscovers the flag,promptand return-path cookies for sign-out and login.pnpm check,pnpm lintandpnpm vitest runpass.Staging check
https://www.stg.bitborg.se/.