Repository navigation
fix: rp-initiated logout & authorize hardening (plan 041 audit follow-ups) - #3197
Conversation
…-ups) Post-merge fixes for defects and test gaps surfaced by an audit of plan 041 (#3194/#3195/#3196). Closes plan 042 items #1, #11 and most of #12. Security / correctness: - AEndSessionForm gates its on-mount local sign-out on `serverRevoked && hintSub === store.user.id` — a cross-site /logout?id_token_hint=<attacker's own token> can no longer force-log-out an unrelated victim who merely renders the page (forced-logout CSRF). The controller forwards `hintSub` (verified hints only) into the payload. - LogoutController bounces back to the RP only when the logout was actually performed (serverRevoked && validated redirect). A hint-less or forged request renders the click-gated confirm page and redirects after sign-out, instead of 302-ing back while the session survives. - Authorize.vue: a fresh login no longer re-prompts prompt=select_account (LoginForm `done` sets accountConfirmed), and the chooser waits for `user` to resolve (no empty-name flash). - /authorize hydration payload trimmed to a ClientSummary DTO (no redirect_uri patterns, grant_types, internal URLs, secret flags). - prompt=none removed from discovery prompt_values_supported + docs (its silent-auth error redirect is unimplemented). - empty `max_age=` is treated as absent instead of coercing to 0 (z.coerce.number('') === 0 would force re-authentication). - AuthorizeForm renders a "Signed in as X - Not you?" switch chip (+ i18n). - Remove the dead OAuth2AuthorizationCode.auth_time field; use specs enums for prompt/error string comparisons instead of literals. Tests: - /logout HTTP e2e matrix (revoke, redirect+state, hint-less no-op, access-token/forged hint no-revoke, unregistered redirect dropped). - server-kit ignoreExpiry (expired+valid-sig accepted; bad-sig/nbf rejected). - auth_time passthrough + auth_time!=refreshed_at pins; redirectUriVerified; confidential refresh exemption; cross-realm login_required no-identity-oracle body; clickjacking headers + trimmed-DTO; max_age empty-vs-0; kit gate spec.
|
Warning Review limit reached
Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughOIDC discovery, authorize/logout flows, and related client UI are updated to narrow exposed data, adjust logout redirect behavior, add subject-checked sign-out handling, and refine ChangesOIDC/logout security hardening and account-switch UI
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant RP
participant LogoutController
participant AEndSessionForm
participant Store
RP->>LogoutController: GET /logout with id_token_hint
LogoutController->>LogoutController: validate hint and build redirect
alt serverRevoked
LogoutController-->>RP: 302 redirect to validated redirect
else not revoked
LogoutController-->>AEndSessionForm: render UI with redirect and hintSub
AEndSessionForm->>Store: logout() when subject matches current user
AEndSessionForm->>RP: navigate to redirect
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
authup
@authup/client-web
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
There was a problem hiding this comment.
Pull request overview
This PR applies post-audit hardening and correctness fixes around OIDC RP-initiated logout (/logout) and the hosted /authorize UX/data surface, with accompanying test backfills, i18n updates, and documentation updates to match the server’s actual capabilities (notably prompt=none).
Changes:
- Harden RP-initiated logout: prevent silent no-op redirects, thread validated redirects to the click-gated UI, and gate any auto-local cleanup on verified subject match.
- Reduce anonymous
/authorizehydration exposure by trimming the client payload to a minimal DTO; align discovery/docs with supportedpromptvalues and handle blankmax_age=. - Add/extend unit + e2e coverage across logout, token verification (
ignoreExpiry), auth-time semantics, redirect verification, and realm/identity leakage constraints.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/server-kit/test/unit/json-web-token.spec.ts | Adds coverage for ignoreExpiry behavior (expired ok, bad signature/nbf still rejected). |
| packages/i18n/src/constants.ts | Introduces new client translation keys for “Signed in as” and “Not you?”. |
| packages/i18n/src/catalogs/fr/client.ts | Adds French strings for the new account-switch chip. |
| packages/i18n/src/catalogs/es/client.ts | Adds Spanish strings for the new account-switch chip. |
| packages/i18n/src/catalogs/en/client.ts | Adds English strings for the new account-switch chip. |
| packages/i18n/src/catalogs/de/client.ts | Adds German strings for the new account-switch chip. |
| packages/core-kit/src/domains/authorization-code/entity.ts | Removes the auth_time field from the authorization-code entity interface. |
| packages/client-web-kit/test/unit/components/workflows/end-session.spec.ts | Adds unit tests for the logout form’s auto-cleanup gate keyed by hintSub. |
| packages/client-web-kit/src/components/workflows/end-session/AEndSessionForm.vue | Adds hintSub/redirect props, gated auto sign-out, and redirect navigation after logout. |
| packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue | Uses @authup/specs enums, adds “Signed in as … Not you?” switch affordance, emits switch. |
| packages/client-web-kit/src/components/workflows/authorize/Authorize.vue | Avoids re-prompt after fresh login; waits for user resolution before select-account chooser; wires switch flow. |
| docs/src/guide/development/api-oauth2.md | Updates docs to stop advertising prompt=none as implemented; clarifies current behavior. |
| apps/server-core/ui/src/pages/logout.vue | Threads hintSub and validated redirect from SSR payload into AEndSessionForm. |
| apps/server-core/test/utils/http.ts | Extends HTTP test helper to support manual redirect handling. |
| apps/server-core/test/unit/http/controllers/workflows/ui-pages.spec.ts | Asserts clickjacking headers and trimmed client DTO fields in SSR hydration. |
| apps/server-core/test/unit/http/controllers/workflows/token/grant-refresh-token.spec.ts | Adds control test for confidential-client cross-realm refresh exemption. |
| apps/server-core/test/unit/http/controllers/workflows/token/grant-authorize.spec.ts | Adds test ensuring cross-realm login_required body does not leak identity/realm data. |
| apps/server-core/test/unit/http/controllers/workflows/logout/end-session.spec.ts | Adds /logout HTTP e2e matrix for verified/forged hints and redirect behavior. |
| apps/server-core/test/unit/http/controllers/entities/realm-openid.spec.ts | Updates discovery test: removes none from prompt_values_supported. |
| apps/server-core/test/unit/core/oauth2/token/issuer/open-id/module.spec.ts | Pins auth_time passthrough (not overwritten by issuance time). |
| apps/server-core/test/unit/core/oauth2/authorization/module.spec.ts | Pins auth_time sourcing from created_at (not refreshed_at). |
| apps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.ts | Adds redirectUriVerified tests for pattern-less vs pattern-matching clients. |
| apps/server-core/test/unit/core/oauth2/authorization/code-request/validator.spec.ts | Adds tests for max_age=0 and blank max_age= semantics. |
| apps/server-core/src/core/oauth2/authorization/code-request/validator.ts | Treats blank max_age= as absent via preprocess (avoids coercion to 0). |
| apps/server-core/src/adapters/http/controllers/workflows/logout/module.ts | Redirects only when server actually revoked; otherwise threads validated redirect into payload. |
| apps/server-core/src/adapters/http/controllers/workflows/authorize/module.ts | Trims anonymous SSR client payload to ClientSummary DTO; keeps realm summary separate. |
| apps/server-core/src/adapters/http/controllers/entities/realm/module.ts | Stops advertising prompt=none in discovery; documents rationale inline. |
| .agents/architecture.md | Updates architecture notes for logout/authorize hardening, DTO trimming, prompt handling, and redirect gating. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/server-kit/test/unit/json-web-token.spec.ts (1)
110-126: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider asserting the specific error variant.
Other tests in this file (lines 90, 141) assert a specific
JWTErrorvariant (e.g.,JWTError.expired(),JWTError.notActiveBefore()). Per thecreateErrorForJWTErrormapping, an invalid signature resolves toJWTError.payloadInvalid(). Asserting the genericJWTErrorbase class here is looser than the sibling tests and could mask a regression where signature failures start throwing a different error type.♻️ Suggested tightening
await expect(async () => { await verifyToken(signedText, { type: 'rsa', key: otherKeyPair.publicKey, }, { ignoreExpiry: true }); - }).rejects.toThrow(JWTError); + }).rejects.toThrow(JWTError.payloadInvalid()); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/server-kit/test/unit/json-web-token.spec.ts` around lines 110 - 126, Tighten the invalid-signature test in json-web-token.spec.ts by asserting the specific JWTError variant instead of the base JWTError class. Update the test around verifyToken and JWTError so it expects JWTError.payloadInvalid(), matching the createErrorForJWTError mapping and the style used by the other JWTError variant assertions in this file.packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue (1)
268-279: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer a
<button>(orrole="button") for the account-switch control."Not you?" performs an in-page action rather than navigation, so
<a href="#">mislabels it as a link for assistive tech. A button-styled control conveys the correct semantics.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue` around lines 268 - 279, The account-switch control in AuthorizeForm.vue is using a link for an in-page action, which gives it the wrong semantics. Update the Not you? control in the identityName block to use a button-style interactive element (or add an appropriate button role if you must keep the tag) and keep the switchAccount click handler behavior unchanged. Use the signedInAsLabel / notYouLabel section and the switchAccount method as the locator for this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue`:
- Around line 268-279: The account-switch control in AuthorizeForm.vue is using
a link for an in-page action, which gives it the wrong semantics. Update the Not
you? control in the identityName block to use a button-style interactive element
(or add an appropriate button role if you must keep the tag) and keep the
switchAccount click handler behavior unchanged. Use the signedInAsLabel /
notYouLabel section and the switchAccount method as the locator for this change.
In `@packages/server-kit/test/unit/json-web-token.spec.ts`:
- Around line 110-126: Tighten the invalid-signature test in
json-web-token.spec.ts by asserting the specific JWTError variant instead of the
base JWTError class. Update the test around verifyToken and JWTError so it
expects JWTError.payloadInvalid(), matching the createErrorForJWTError mapping
and the style used by the other JWTError variant assertions in this file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: adfe4009-3249-4ee6-bc2c-2f1e80dffdb4
📒 Files selected for processing (28)
.agents/architecture.mdapps/server-core/src/adapters/http/controllers/entities/realm/module.tsapps/server-core/src/adapters/http/controllers/workflows/authorize/module.tsapps/server-core/src/adapters/http/controllers/workflows/logout/module.tsapps/server-core/src/core/oauth2/authorization/code-request/validator.tsapps/server-core/test/unit/core/oauth2/authorization/code-request/validator.spec.tsapps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.tsapps/server-core/test/unit/core/oauth2/authorization/module.spec.tsapps/server-core/test/unit/core/oauth2/token/issuer/open-id/module.spec.tsapps/server-core/test/unit/http/controllers/entities/realm-openid.spec.tsapps/server-core/test/unit/http/controllers/workflows/logout/end-session.spec.tsapps/server-core/test/unit/http/controllers/workflows/token/grant-authorize.spec.tsapps/server-core/test/unit/http/controllers/workflows/token/grant-refresh-token.spec.tsapps/server-core/test/unit/http/controllers/workflows/ui-pages.spec.tsapps/server-core/test/utils/http.tsapps/server-core/ui/src/pages/logout.vuedocs/src/guide/development/api-oauth2.mdpackages/client-web-kit/src/components/workflows/authorize/Authorize.vuepackages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vuepackages/client-web-kit/src/components/workflows/end-session/AEndSessionForm.vuepackages/client-web-kit/test/unit/components/workflows/end-session.spec.tspackages/core-kit/src/domains/authorization-code/entity.tspackages/i18n/src/catalogs/de/client.tspackages/i18n/src/catalogs/en/client.tspackages/i18n/src/catalogs/es/client.tspackages/i18n/src/catalogs/fr/client.tspackages/i18n/src/constants.tspackages/server-kit/test/unit/json-web-token.spec.ts
💤 Files with no reviewable changes (1)
- packages/core-kit/src/domains/authorization-code/entity.ts
The account-switch affordance is an action, not navigation — render it as a <button type="button"> styled like a link instead of an <a href="#"> so it has correct button semantics and keyboard behavior (Enter/Space activation), and matches the rest of the form's actions.
|
@coderabbitai pause |
✅ Action performedReviews paused. |
The prompt=select_account chooser reappeared right after entering username/password on the hosted /authorize page. The previous fix keyed off LoginForm's `done` emit, but on login the access-token flip re-renders Authorize and unmounts LoginForm before `done` fires, so the flag that skips the chooser was never set — the chooser stayed. Key off the store's LOGGED_IN dispatcher event instead. It is emitted only by an explicit login() (the form), never by a session restored from cookies (resolve() → RESOLVED), so a lingering session still gets the chooser while a fresh login skips it — independent of component mount/unmount timing. Adds a component spec pinning all three cases (lingering shows, LOGGED_IN skips, RESOLVED does not suppress).
|
@coderabbitai review |
✅ Action performedReview finished.
|
Post-merge fixes for defects and test gaps surfaced by an audit of plan 041 (#3194 / #3195 / #3196). Closes plan 042 items #1, #11, and most of #12. No breaking API changes; all changes are server-authoritative fixes with kit/UX follow-through.
Security / correctness
AEndSessionFormauto-cleared local state on anyserverRevoked, so a cross-siteGET /logout?id_token_hint=<attacker's own id_token>(which revokes the attacker's own session →serverRevoked=true) force-logged-out any victim who merely rendered the page (store.logout()is local-only, so it acts on whoever's browser rendered it). Now gated onserverRevoked && hintSub === store.user.id; the controller forwardshintSub(verified hints only) into the payload.LogoutControllerredirected wheneverpost_logout_redirect_urivalidated, regardless of whether a session was revoked — a hint-less RP round-trip 302'd back while the authup session survived. The server-side bounce now fires only whenserverRevoked && redirect; otherwise the validated redirect is threaded into the render payload and the click-gatedAEndSessionFormperforms the bearer-authenticated sign-out, then navigates to it.prompt=select_accountafter fresh login (medium UX). A just-completed credential entry no longer re-prompts "Continue as X" (LoginForm'sdonesetsaccountConfirmed); the chooser also waits for the storeuserto resolve (no "Continue as <empty>" flash)./authorizeover-disclosure (low).serve()now ships aClientSummaryDTO (id/name/display_name/built_in/created_at) — neverredirect_uripatterns (the trusted-origin set),grant_types, internal URLs, or secret storage flags.prompt=none(low). Removed from discoveryprompt_values_supported+ docs — the silent-auth error redirect is unimplemented, so advertising it promised a capability the server lacks.max_age=empty (low). Treated as absent instead of coercing to0(z.coerce.number('') === 0would silently force re-authentication).OAuth2AuthorizationCode.auth_timefield; replaced hardcoded prompt/error literals with@authup/specsenums.Tests (backfill of the plan's load-bearing matrix)
/logoutHTTP e2e (logout/end-session.spec.ts): verified-hint revoke, verified-hint+redirect 302 w/ state, hint-less no-op renders page, access-token-as-hint no-revoke, forged-hint no-revoke, unregisteredpost_logout_redirect_uridropped, discovery reachable.server-kitignoreExpiry: expired-but-valid-signature accepted; bad signature andnbfstill rejected.auth_timepassthrough (open-id issuer) +auth_time ≠ refreshed_atpin (authorization module);redirectUriVerified(code-request verifier); confidential refresh exemption; cross-realmlogin_requiredno-identity-oracle body; clickjacking headers + trimmed-DTO assertions (ui-pages.spec.ts);max_ageempty-vs-0;AEndSessionFormhint-sub gate (kit).Docs
.agents/architecture.md(logout redirect/gate, hydration DTO,prompt=nonenon-advertisement, fresh-login chooser + switch chip),docs/api-oauth2.md, and status annotations on.agents/plans/042.Verification
Full build (22 projects), lint,
check:types, and suites green: server-kit 13, i18n 77, client-web-kit 15, server-core 1152/1153. The one failure issession.spec.ts(counts the admin's own sessions; races with parallel suites doing admin logins in the shared DB) — pre-existing flakiness, deterministic 6/6 in isolation.Deliberate scope note
An HTTP e2e for realm-gate layer 2 (cross-realm code →
/tokeninvalid_grant, pinning therealmId: client.realm_idwiring) is not included: it is unreachable via the public authorize API now that layer 1 blocks cross-realm issuance, so it needs an IdP-callback harness. The verifier's realm semantics are already unit-tested. Tracked in plan 042 #12.Summary by CodeRabbit
max_agehandling so empty values are treated as unset.prompt=none).promptsupport and interactive behavior.