Repository navigation
fix(client-web-kit): observe the promise-share wrapper's derived promise - #3214
Conversation
createPromiseShareWrapperFn attached its clear-callback via .finally() and dropped the derived promise — every rejected refreshSession()/resolve() produced an unobserved rejection alongside the handled one (console noise in browsers, a potential process-level unhandledRejection during SSR). Attach the callback via .then(clear, clear) instead.
…idge Plan-045 PR 1 — pin current observable store behavior before the auth-state redesign: - login dispatcher event ORDER incl. the expire-date-before-token ordering and the missing REALM_UPDATED on introspection (realm cookie is never persisted from that path) - login failure modes: dangling LOGGING_IN, and the tokenResolved latch that leaves a token-only session whose realm never resolves - logout local-only semantics: both token revokes, swallowed revoke failures, and the absence of any /sessions request - resolve(): refresh-failure cleanup (no RESOLVED), the refresh retry branch after a failed introspection, the anonymous RESOLVING/RESOLVED no-op, and promise-sharing across concurrent calls - exchangeAuthorizationCode: success-path cleanup revoking the previous tokens with no lifecycle events, and failure leaving prior state intact - id_token retention across a refresh grant via resolve() - installStore cookie bridge: synchronous hydration (incl. the write-back echo), per-event cookie persistence on login, full unset on logout
|
Warning Review limit reached
Next review available in: 32 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 (3)
✨ 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: |
…ore-apply contract The #3214 characterization spec pinned the pre-047.3 login lifecycle; login() now clears previous identity state between the grant and the apply, so the unset events precede the apply sequence and REALM_UPDATED legitimately fires exactly once (the cleanup unset — introspection still bypasses setRealm).
…#3216) * fix(server-core): reject clients without registered redirect_uri patterns at /authorize OAuth 2.1 posture: a pattern-less client left data.redirect_uri entirely unchecked (any attacker-supplied URI passed, merely flagged redirectUriVerified=false) — the server would issue a code to an arbitrary redirect target. The code-request verifier now throws redirect_uri_mismatch for a client with no registered patterns, before any code issuance. redirectUriVerified is false only when the request carries no redirect_uri. * fix(client-web-kit): gate the authorize abort redirect on a verified redirect_uri Every other redirect in the authorize ladder is gated on redirectUriVerified, but AuthorizeForm.abort() navigated to codeRequest.redirect_uri unconditionally — for a pattern-less client a user click on Deny was an open redirect (error params only). The form now takes a fail-closed redirectUriVerified prop threaded from Authorize.vue and renders a localized stay-on-page notice instead of navigating when the redirect_uri is unverified. * fix(client-web-kit): escape the select_account chooser when the user never resolves loggedIn/realmId are truthy for ANY identity type, but the chooser needs the resolved user — a non-user (client/robot) lingering session, or a transient userinfo failure (userResolved latched true before the call), left the page on a permanent spinner with no way forward; buildAuthorizeURL defaults prompt=select_account, so this was the default path. A failed resolveUser() no longer latches, the page re-resolves once, and a settled null user now renders the account prompt in switch-only mode (AAccountPrompt hides "Continue as" for an empty identityName) instead of the loading text. Also fixes the promise-share wrapper spawning an unhandled rejection from its internal .finally() chain whenever the shared promise rejects. * fix(client-web-kit): clear previous identity state before applying a password grant applyTokenGrantResponse deliberately retains an existing id_token when a response carries none (the refresh path) — but login() applied the password-grant response without a preceding cleanup(), so a stale id_token survived onto a newly-authenticated user. Reused for account switching, an RP-logout would then send the OLD user's id_token as id_token_hint and revoke the wrong session. login() now runs cleanup() between the grant succeeding and applying the response, mirroring exchangeAuthorizationCode. * fix(server-core): fail closed on the end-session aud cross-check and resolve name-form client ids Three fail-open shapes in OAuth2EndSessionService.verify(): - an aud-less verified hint paired with a request client_id silently skipped the cross-check (guarded on audiences.length > 0) — it now counts as unverified; - the id_token aud is the client UUID, so a name-form client_id (web) always failed the cross-check and silently degraded the logout to the confirm page — a non-UUID client_id is now resolved (realm from the request hint, else the VERIFIED hint's own realm claim; never claims of an unverified hint, no master fallback) and compared by its resolved UUID, failing closed when it does not resolve; - a supplied-but-unknown realm key degraded to an UNSCOPED client name lookup — it now skips client resolution entirely (no name, no redirect), and a name-form client_id with no realm key anywhere fails closed too (ambiguous: every realm has a built-in web client — same rule as the /authorize verifier). UUID client ids, including the sole-aud-derived one, resolve globally as before. * fix: require a user sub_kind for the end-session auto-clear gate The forced-logout CSRF gate in AEndSessionForm compared hintSub against the local USER id but ignored the subject kind — the server revoke checks both sub and sub_kind. The logout controller now forwards hintSubKind (verified hints only) through the SSR page into the form, and the auto-clear requires hintSubKind === 'user' in addition to the sub match; a missing kind fails closed (no auto-clear). * fix(server-core): fail closed on dangling realm relations in the authorize flow The realm-binding gate dereferenced identity.data.realm.id unguarded, and the code issuer read realm id/name the same way — a realm row deleted out from under a live identity produced a raw TypeError → HTTP 500. The gate now treats a missing realm relation as a mismatch (clean login_required, still no identity data in the body) and the issuer throws identityInvalid before building the code. * fix(server-core): derive the at_hash digest from the id_token signing algorithm buildOAuth2TokenHash hardcoded SHA-256 with a 16-byte left half — only coincidentally correct while every key is RS256. The digest (and its half-length, per OIDC Core §3.1.3.6) now follows the id_token's JWS alg (*256→SHA-256/16, *384→SHA-384/24, *512→SHA-512/32; an unrecognized alg throws instead of silently defaulting), and the authorization_code grant passes the realm signing key's signature_algorithm, resolved via a DI-injected key repository. Behavior today is unchanged; a future multi-algorithm key can no longer silently mint wrong hashes. * test(server-core): pin the prompt=login freshness window as the deliberate contract The 60s promptLoginMaxAge window is a documented stateless approximation, not an accident: a sub-window session satisfies prompt=login without re-auth (it absorbs the hosted login→consent round-trip), an over-window session throws login_required, and max_age=0 stays stricter than prompt=login (the documented inversion). Also covers the dangling-realm login_required guard. * docs: record the plan 047 hardening contracts in the architecture notes - end-session aud cross-check: fail-closed shape + name-form client_id resolution and the fail-closed realm-key rules - pattern-less clients rejected at /authorize; redirectUriVerified semantics - AuthorizeForm abort gate, select_account chooser escape hatch, login() cleanup-before-apply, hintSubKind auto-clear gate - at_hash digest derived from the signing alg; note that no c_hash is minted (code-only flow) - prompt=login window pinned as deliberate contract; prompt=none client-side enforcement recorded as a known limitation (server-side silent path scoped separately) - post_logout_redirect_uri column is text, the 2000-char cap is the request param validator's - client-web logout page comment updated for the name-form client_id resolution * test(client-web-kit): repin the login event order for the cleanup-before-apply contract The #3214 characterization spec pinned the pre-047.3 login lifecycle; login() now clears previous identity state between the grant and the apply, so the unset events precede the apply sequence and REALM_UPDATED legitimately fires exactly once (the cleanup unset — introspection still bypasses setRealm).
Summary
Plan-045 PR 1 (characterization pass) — the new store lifecycle specs exposed a real defect, fixed here alongside the suite that caught it.
Fix:
createPromiseShareWrapperFn(the dedup wrapper aroundresolve()/refreshSession()) attached its clear-callback via.finally()and dropped the derived promise. Whenever the shared promise rejected — any failed refresh or resolve — that derived promise rejected unobserved, producing anunhandledrejectionalongside the properly handled one (console noise in browsers, and a potential process-level unhandled rejection during SSR with restored cookies). The callback now rides.then(clear, clear), which never rejects. No behavioral change otherwise.Characterization tests (
test/unit/core/store/lifecycle.spec.ts,install-cookies.spec.ts) pin the store's current observable behavior ahead of the plan-045 auth-state redesign:REALM_UPDATEDon introspection (the realm cookie is never persisted from that path)LOGGING_IN; thetokenResolvedlatch that leaves a token-only session whose realm never resolveslogout()local-only semantics: both token revokes, swallowed revoke failures, no/sessionsrequest (plan-041 invariant)resolve(): refresh-failure cleanup (noRESOLVED), the refresh retry branch, the anonymousRESOLVING/RESOLVEDno-op, promise-sharing across concurrent callsexchangeAuthorizationCode: success-path cleanup revoking the previous tokens with no lifecycle events; failure leaves prior state intactid_tokenretention across a refresh grant end-to-endinstallStorecookie bridge: synchronous hydration (incl. the write-back echo), per-event persistence on login, full unset on logoutTest plan
npm run test --workspace=packages/client-web-kit— 12 files, 69 tests greenvue-tsc --noEmit(kit has nocheck:typesscript)npm run build -w packages/client-web-kitgreen