Skip to content

feat: retain the id_token in the kit store & round-trip client-web logout - #3201

Merged
tada5hi merged 2 commits into
masterfrom
feat/kit-id-token-logout-roundtrip
Jul 8, 2026
Merged

tada5hi merged 2 commits into
masterfrom
feat/kit-id-token-logout-roundtrip

Conversation

@tada5hi

@tada5hi tada5hi commented Jul 8, 2026 •

Copy link
Copy Markdown
Collaborator

Plan 042 items 8a + 8. Independent of the server-core PRs (#3198–#3200) — branches off master.

8a — the kit store retains the id_token

applyTokenGrantResponse kept only the access/refresh tokens, so no kit-based RP could pass an id_token_hint to the new end_session_endpoint (#3196) — every logout degraded to the click-gated confirm page.

  • new idToken ref + setIdToken setter emitting StoreDispatcherEventName.ID_TOKEN_UPDATED
  • cookie persistence via a new CookieName.ID_TOKEN (@authup/core-http-kit) + the install-time read/write handlers, mirroring the access/refresh token pattern
  • cleared in cleanup()
  • applyTokenGrantResponse retains the existing id_token when a response carries none — a refresh grant returns no id_token, and the session is unchanged, so the hint must survive a token refresh

8 — client-web round-trips through /logout

apps/client-web/pages/logout.vue previously just navigateTo('/login') after the interceptor's local cleanup — the shared authup-origin session survived. Now the page owns the sign-out:

  • it deliberately drops REQUIRED_LOGGED_OUT — that meta made the routing interceptor run store.logout() before the page's setup, discarding the id_token the round-trip needs
  • on mount it captures idToken/realmId, runs the local-only store.logout(), then hard-redirects to buildEndSessionURL({ baseURL, idTokenHint, clientId: 'web', realmId, postLogoutRedirectUri: <origin>/login })
  • with the hint, the server revokes the session and bounces straight back to /login; without it, the server's click-gated confirm page returns to /login

store.logout() stays local-only — the round-trip is the chosen mechanism, not a DELETE /sessions/@me (established in plan 041: that collides with the #3191 interactive-login session reuse → self-DoS of fresh logins).

Tests

New packages/client-web-kit/test/unit/core/store/id-token.spec.ts: the grant response id_token is retained; cleared on logout; and a refresh-shaped response (no id_token) keeps the retained one. Full client-web-kit suite green (21), core-http-kit green (19), client-web nuxi typecheck clean.

Summary by CodeRabbit

  • New Features

    • Sign-out now keeps the login flow seamless by using the current session token during logout redirects.
    • The client app now shows a loading state while completing sign-out instead of immediately redirecting.
  • Bug Fixes

    • Improved logout reliability by preserving the token needed for post-logout redirects.
    • Logout now clears local session data while still supporting the full sign-out round trip.
  • Documentation

    • Updated architecture notes to describe the revised logout behavior.

…gout (plan 042)

The kit store discarded the grant response's id_token, so no kit RP could
pass an id_token_hint to the authup end_session_endpoint — every logout
degraded to the click-gated confirm page.

- add an `idToken` ref to the store (ID_TOKEN_UPDATED dispatcher event,
  CookieName.ID_TOKEN persistence, cleared in cleanup); applyTokenGrantResponse
  retains the existing value when a response carries none (refresh grants)
- client-web pages/logout.vue now performs the RP-initiated round-trip: it
  drops REQUIRED_LOGGED_OUT (so the interceptor no longer logs out before the
  page runs), captures idToken/realmId, runs the local-only store.logout(),
  then redirects to buildEndSessionURL(...) with the id_token hint and a
  post_logout_redirect_uri back to /login

store.logout() stays local-only — the round-trip ends the shared authup
session, never a DELETE /sessions/@me (which would collide with #3191
session reuse).
Copilot AI review requested due to automatic review settings July 8, 2026 10:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 324648c8-a824-4b2b-a9bd-81741a9ba27c

📥 Commits

Reviewing files that changed from the base of the PR and between 54bdaf8 and 226ca57.

📒 Files selected for processing (8)
  • .agents/architecture.md
  • apps/client-web/pages/logout.vue
  • packages/client-web-kit/src/core/store/create.ts
  • packages/client-web-kit/src/core/store/dispatcher/constants.ts
  • packages/client-web-kit/src/core/store/dispatcher/types.ts
  • packages/client-web-kit/src/core/store/install.ts
  • packages/client-web-kit/test/unit/core/store/id-token.spec.ts
  • packages/core-http-kit/src/cookies.ts

📝 Walkthrough

Walkthrough

Adds idToken retention to the client-web-kit store with a new dispatcher event and cookie persistence, updates the client-web logout page to redirect to the RP-initiated end-session endpoint using an id_token_hint, adds a CookieName.ID_TOKEN enum member, unit tests, and documentation.

Changes

Persist and use id_token for RP-initiated logout

Layer / File(s) Summary
Cookie and dispatcher event contracts
packages/core-http-kit/src/cookies.ts, packages/client-web-kit/src/core/store/dispatcher/constants.ts, packages/client-web-kit/src/core/store/dispatcher/types.ts
Adds CookieName.ID_TOKEN and StoreDispatcherEventName.ID_TOKEN_UPDATED event with a string | null payload type.
Store idToken state and grant handling
packages/client-web-kit/src/core/store/create.ts
Adds idToken ref and setIdToken setter emitting the update event, clears idToken on cleanup, retains it across refresh grants lacking id_token, and exposes it from createStore.
Cookie persistence wiring
packages/client-web-kit/src/core/store/install.ts
Reads CookieName.ID_TOKEN into store.idToken on init and syncs the cookie on ID_TOKEN_UPDATED events.
Logout page RP-initiated redirect
apps/client-web/pages/logout.vue
Reads idToken/realmId on mount, calls store.logout() for local cleanup, then redirects via buildEndSessionURL with idTokenHint; replaces immediate /login navigation and REQUIRED_LOGGED_OUT meta with auth layout and a spinner.
Unit tests and documentation
packages/client-web-kit/test/unit/core/store/id-token.spec.ts, .agents/architecture.md
Adds tests for idToken lifecycle (init, login, logout, refresh retention) and documents the id_token retention/logout behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant LogoutPage as logout.vue
  participant Store as client-web-kit Store
  participant EndSessionEndpoint as /logout endpoint

  Browser->>LogoutPage: mount /logout
  LogoutPage->>Store: read idToken, realmId
  LogoutPage->>Store: store.logout()
  Store-->>LogoutPage: local tokens/cookies cleared
  LogoutPage->>EndSessionEndpoint: redirect with id_token_hint, postLogoutRedirectUri
Loading
sequenceDiagram
  participant Client
  participant Store
  participant Dispatcher
  participant Cookies

  Client->>Store: token grant response (login/refresh)
  Store->>Store: set idToken if response.id_token present, else retain previous
  Store->>Dispatcher: emit ID_TOKEN_UPDATED(idToken)
  Dispatcher->>Cookies: set or unset CookieName.ID_TOKEN
Loading

Possibly related PRs

  • authup/authup#3196: Adds the server-side /logout controller/service that verifies the id_token_hint (aud, expiry, sid/sub_kind) sent by the client changes in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: retaining the id_token in the kit store and updating client-web logout round-tripping.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/kit-id-token-logout-roundtrip

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tada5hi tada5hi changed the title feat: retain the id_token in the kit store & round-trip client-web logout (plan 042) feat: retain the id_token in the kit store & round-trip client-web logout Jul 8, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

authup

npm i https://pkg.pr.new/authup@3201

@authup/client-web

npm i https://pkg.pr.new/@authup/client-web@3201

@authup/server-core

npm i https://pkg.pr.new/@authup/server-core@3201

@authup/access

npm i https://pkg.pr.new/@authup/access@3201

@authup/client-web-kit

npm i https://pkg.pr.new/@authup/client-web-kit@3201

@authup/client-web-kit-theme

npm i https://pkg.pr.new/@authup/client-web-kit-theme@3201

@authup/client-web-nuxt

npm i https://pkg.pr.new/@authup/client-web-nuxt@3201

@authup/client-web-theme

npm i https://pkg.pr.new/@authup/client-web-theme@3201

@authup/core-http-kit

npm i https://pkg.pr.new/@authup/core-http-kit@3201

@authup/core-kit

npm i https://pkg.pr.new/@authup/core-kit@3201

@authup/core-realtime-kit

npm i https://pkg.pr.new/@authup/core-realtime-kit@3201

@authup/errors

npm i https://pkg.pr.new/@authup/errors@3201

@authup/i18n

npm i https://pkg.pr.new/@authup/i18n@3201

@authup/kit

npm i https://pkg.pr.new/@authup/kit@3201

@authup/server-adapter-kit

npm i https://pkg.pr.new/@authup/server-adapter-kit@3201

@authup/server-adapter-node

npm i https://pkg.pr.new/@authup/server-adapter-node@3201

@authup/server-adapter-socket-io

npm i https://pkg.pr.new/@authup/server-adapter-socket-io@3201

@authup/server-adapter-web

npm i https://pkg.pr.new/@authup/server-adapter-web@3201

@authup/server-kit

npm i https://pkg.pr.new/@authup/server-kit@3201

@authup/server-test-kit

npm i https://pkg.pr.new/@authup/server-test-kit@3201

@authup/specs

npm i https://pkg.pr.new/@authup/specs@3201

commit: 226ca57

…olves the client

logout.vue passed client_id=web (the name) but the id_token aud is the
web client UUID. The end-session service aud/client_id cross-check then
failed, clearing hintVerified, so the session was never revoked and the
browser never bounced back to /login — every client-web logout silently
degraded to the confirm page, defeating the round-trip. Omitting client_id
lets the service resolve the client from the hint sole aud.
@tada5hi
tada5hi merged commit 500d4df into master Jul 8, 2026
12 checks passed
@tada5hi
tada5hi deleted the feat/kit-id-token-logout-roundtrip branch July 8, 2026 13:56
@github-actions github-actions Bot mentioned this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants