Refactor: DO-11383 store auth token data server-side#633
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2467d3349d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a43cdb5804
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
sam-causalens
left a comment
There was a problem hiding this comment.
This looks great Krys, thanks 🙏
Motivation and Context
Large OIDC group claims can overflow browser cookie limits when auth token data is stored directly in cookies. Some customer IDPs also expose groups through non-standard claim names or string formats, and auth failure paths need to fail clearly instead of looping users through login.
This PR moves browser auth state to a single opaque session cookie, stores the full auth session server-side, and tightens OIDC session refresh, group extraction, userinfo handling, auth error routing, and local QA coverage.
Implementation Description
Auth session creation now stores raw auth tokens, token data, groups, ID tokens, and refresh tokens in the generic server-side auth session store. The browser receives only the opaque
dara_session_token; application code continues to use the existing resolved auth context by the time user code runs.Refresh now runs server-side from the stored refresh token and updates the same session record after a successful refresh. Missing in-memory session entries are treated as expired sessions, terminal refresh failures evict the stored session, and stale cookie-backed opaque handles are rejected directly instead of being decoded as raw JWTs. The old OIDC-only ID token cache and refresh-token cookie path were removed.
OIDC group handling now supports a configurable group claim name, plus list, comma-delimited string, and single-string claim values. Comma-delimited strings are parsed with CSV semantics while preserving the original full string for exact matching. When
SSO_USE_USERINFO=true, login and refresh now require userinfo to succeed and log clear provider failure reasons.Frontend auth error handling now uses an option bag instead of positional booleans. Normal app requests send authentication failures to
/login, while authorization, provider, bad-request, and OIDC callback validation failures go to/errorto avoid login loops. WebSocket auth recovery can also restart reconnect attempts after server-side HTTP session recovery.A local OIDC provider test tool was added under
tools/local-oidc-providerwith controllable profiles for large claims, userinfo, refresh behavior, group formats, non-standardmemberOfgroup claims, logout redirects, and failure cases.Any new dependencies Introduced
No Dara runtime dependencies. The local QA provider is self-contained under
tools/local-oidc-providerand declares its own npm dependencies.How Has This Been Tested?
DARA_TEST_FLAG=True poetry run pytest tests/python/test_oidc_auth.pyDARA_TEST_FLAG=True poetry run pytest tests/python/test_auth.py -k 'invalid_cookie_clears_auth_cookies_without_refresh_token or refresh_token_terminal_failure_removes_session or refresh_token_concurrent_requests'DARA_TEST_FLAG=True poetry run pytest tests/python/test_oidc_auth.py -k 'missing_id_token or expired_id_token or idp_error or refresh'pnpm --filter @darajs/core exec vitest --run tests/js/auth.spec.tsx tests/js/websocket-auth-recovery.spec.tsxpnpm --filter @darajs/core exec tsc --noEmitpnpm --filter @darajs/components exec tsc --noEmitpnpm --filter @darajs/core buildpoetry anthology run lintpoetry anthology run format-checkQA_OIDC_ISSUER=http://localhost:9101 npm run smokefromtools/local-oidc-providerManual browser QA with the demo app and
tools/local-oidc-providercovered:dara_session_tokenneeded after login.huge-groups, verifying opaque sessions avoid cookie overflow.groups-string,single-group-string, missing group, and missing group claim profiles.SSO_GROUP_CLAIM_NAME=memberOfand themember-of-groupsprofile.short-expiry,refresh-reuses-token,refresh-loses-group, andno-refresh-tokenprofiles.SSO_USE_USERINFO=true: allowed userinfo groups, denied userinfo groups, and userinfosubmismatch.PR Checklist:
Screenshots (if appropriate):
N/A