Repository navigation
Closed
Labels
priority: highHigh prioritytype: bugSomething isn't workingworkload: hoursLikely takes hours to resolve
Milestone
Description
Found in the pre-release review of Krini 0.1.0. Session handling with a real identity provider has several gaps that should be fixed before the tag. This issue also covers #106 (a refresh in flight can undo the logout).
Why
- Refresh errors don't follow RFC 6749.
POST /auth/api/refreshends the session (clears cookies, applies the replay window) only when the token endpoint answers 401. RFC 6749 §5.2 uses 400invalid_grantfor an expired, revoked or reused refresh token and 401 only forinvalid_client. So a dead refresh token never ends the session, and a rotated client secret (401invalid_client) wipes every user's session. - One status for every failure. The route answers 401 to everything (no refresh token, IdP 503, timeout), and
useTokenRefreshsends the tab to/auth/loginon any error. A short IdP outage sends every open tab to the login page and loses unsaved form input. - Stale
token_expires_at. The cookie lives for a fixed 30 days and is never deleted, so after a session ends without logout every dashboard visit, including anonymous ones, redirects to/auth/loginuntil it expires. The stored value is also shifted by 5 minutes, and the hook subtracts another 5, so the refresh fires about 10 minutes early. - Refresh after logout restores the session (fix: a refresh in flight can undo the logout #106). A refresh response that arrives after the logout response sets the session cookies again;
/auth/api/tokenand/auth/api/user-infodon't checklogout_marker, and logout doesn't stop the refresh timer. The existing unit test mutates the request's own cookie jar and doesn't test the real race. id_tokencookie can expire before the session. It gets the access token's max-age and is rewritten only if the refresh response has an ID token (optional per OIDC Core 12.2). Once it's gone, the user menu shows "Anonymous" and the compute UI is hidden, although the tokens are valid. A refreshed ID token'ssub/issaren't compared with the session's.- Smaller gaps:
POST /auth/api/refreshhas no Origin check (logout has one); therefresh_tokencookie's max-age isn't capped at the 30 days the privacy notice promises; the docs say concurrent refreshes across pods "can log the user out", while the actual effect is a redirect to the login page (related: fix: concurrent refreshes log users out #93, fix: share the refresh replay check across pods #107); no tests cover refresh failures, and the e2e mock always answers 200 to therefresh_tokengrant.
Expected result
- 400
invalid_grant(and 401) from the token endpoint end the session: all session cookies are cleared (unless the replay window applies) and the route answers 401 -
invalid_clientand other provider or network errors keep the cookies, are logged, and the route answers 503 - The hook retries transient errors with backoff, redirects to login only when the session is over, and never redirects anonymous visitors; no refresh token clears
token_expires_atwithout a redirect -
token_expires_atstores the real access token expiry and lives as long as the session - A refresh that finishes after the logout doesn't restore the session; token and user-info refuse requests after logout; logout stops the refresh timer and waits for a refresh in flight
-
id_tokenlives as long as the session; a refreshed ID token with a differentsuborissis rejected - The refresh route checks the Origin like logout; the
refresh_tokenmax-age is capped at 30 days - Docs updated:
login.md,helm-chart.md,upgrading.md,values.yaml, privacy notice - Unit tests for each case, and a refresh-failure mode in the e2e mock with e2e tests
Metadata
Metadata
Assignees
Labels
priority: highHigh prioritytype: bugSomething isn't workingworkload: hoursLikely takes hours to resolve
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: cover the pre-release fixes in the notes