Skip to content

Revoke the access token before completing sign out - #70

Merged
brionmario merged 3 commits into
thunder-id:mainfrom
brionmario:feat/revoke-token-on-signout
Aug 12, 2026
Merged

Revoke the access token before completing sign out#70
brionmario merged 3 commits into
thunder-id:mainfrom
brionmario:feat/revoke-token-on-signout

Conversation

@brionmario

@brionmario brionmario commented Aug 12, 2026

Copy link
Copy Markdown
Member

Purpose

signOut() only cleared the local session and, when RP-Initiated Logout is enabled, redirected to the OP's end_session_endpoint. It never revoked the access token itself, so a client-side sign out could leave the token valid at the OP.

Approach

Adds a tokenLifecycle.revokeToken.revokeOnSignOut config (default true) and has signOut() revoke the access token at the OP's revocation_endpoint first, before the existing RP-Initiated Logout / local-only sign-out logic runs.

Revocation is best-effort: if it fails (no revocation_endpoint advertised, network error, non-200 response — e.g. for non-OAuth sessions), the error is caught and logged at debug level, and sign out proceeds exactly as it did before, since the local session must be cleared regardless.

Set tokenLifecycle: { revokeToken: { revokeOnSignOut: false } } to opt out and skip revocation entirely.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features

    • Access tokens are now automatically revoked during sign-out by default.
    • Token revocation can be disabled through configuration.
    • Revocation failures no longer prevent users from signing out.
  • Documentation

    • Updated endpoint documentation with ThunderID branding.
    • Clarified configuration options for token lifecycle management.

Adds tokenLifecycle.revokeToken.revokeOnSignOut config (default true) so
signOut() revokes the access token at the OP's revocation_endpoint before
clearing the local session. Revocation is best-effort: failures don't
block sign out since the local session is cleared regardless.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@brionmario, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 21 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a2ceed0e-ef69-4fbc-8a49-d4947cc7f830

📥 Commits

Reviewing files that changed from the base of the PR and between 63337ef and 7087cff.

📒 Files selected for processing (3)
  • packages/browser/src/ThunderIDBrowserClient.ts
  • packages/javascript/src/ThunderIDJavaScriptClient.ts
  • packages/javascript/src/models/config.ts
📝 Walkthrough

Walkthrough

The configuration model adds optional sign-out token revocation. The browser client revokes the access token before logout by default, logs revocation failures, and continues sign-out.

Changes

Sign-out token revocation

Layer / File(s) Summary
Revocation configuration and documentation
packages/javascript/src/models/config.ts
Adds tokenLifecycle.revokeToken.revokeOnSignOut, enabled by default. Updates endpoint branding and removes a platform-specific preference remark.
Best-effort revocation during sign-out
packages/browser/src/ThunderIDBrowserClient.ts
signOut conditionally calls revokeAccessToken(sessionId) before logout. Revocation failures are logged without blocking sign-out.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the primary change: revoking the access token before sign-out completes.
Description check ✅ Passed The description includes all required sections and clearly explains the purpose, approach, configuration, failure handling, and impact.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/javascript/src/models/config.ts (1)

432-449: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Correct the revokeOnSignOut documentation.

When revokeOnSignOut is false, signOut() still performs RP-Initiated Logout by default. State that rpInitiatedLogout: false is also required for local-only sign-out.

🤖 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/javascript/src/models/config.ts` around lines 432 - 449, Update the
revokeToken.revokeOnSignOut documentation to clarify that setting it to false
only skips token revocation; local-only sign-out also requires configuring
rpInitiatedLogout: false.

Source: Coding guidelines

🤖 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.

Inline comments:
In `@packages/browser/src/ThunderIDBrowserClient.ts`:
- Around line 377-382: Update signOut() around revokeAccessToken() to bound the
revocation wait with a timeout, aborting or rejecting the request after a finite
duration so stalled endpoints cannot block local cleanup. Preserve the existing
debug logging and ensure sign-out continues after timeout or other revocation
failures.
- Around line 372-384: Separate token revocation from session cleanup by adding
a core-client method that only sends the revocation request and does not clear
the session. Update signOut() to call this request-only method before resolving
the RP-Initiated Logout URL, while preserving the existing cleanup after URL
resolution; do not use the public revokeAccessToken() override in this flow.
- Around line 372-384: The signOut flow must build the logout URL before
revokeAccessToken clears the session, then use that precomputed URL during
sign-out. Also bound the revocation request inside revokeAccessToken with the
existing timeout/AbortSignal pattern so a stalled fetch cannot block signOut
indefinitely.

In `@packages/javascript/src/models/config.ts`:
- Around line 433-449: Update the JSDoc for revokeToken.revokeOnSignOut in the
configuration definition to state that disabling revocation skips token
revocation while sign-out continues according to rpInitiatedLogout, rather than
claiming it only clears the local session.

---

Nitpick comments:
In `@packages/javascript/src/models/config.ts`:
- Around line 432-449: Update the revokeToken.revokeOnSignOut documentation to
clarify that setting it to false only skips token revocation; local-only
sign-out also requires configuring rpInitiatedLogout: false.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 06c16f9b-1a71-4a56-b880-36e9ea01a545

📥 Commits

Reviewing files that changed from the base of the PR and between 372a59a and 63337ef.

📒 Files selected for processing (2)
  • packages/browser/src/ThunderIDBrowserClient.ts
  • packages/javascript/src/models/config.ts

Comment thread packages/browser/src/ThunderIDBrowserClient.ts Outdated
Comment thread packages/browser/src/ThunderIDBrowserClient.ts Outdated
Comment thread packages/javascript/src/models/config.ts
…ix doc

Extracts a revocation-request-only core method so signOut() can resolve the
RP-Initiated Logout URL (needs the ID token) before revoking the access
token, instead of the public revokeAccessToken() override clearing the
session prematurely. Bounds the revocation fetch with a timeout so a
stalled revocation_endpoint can't block signOut() indefinitely, and
corrects the revokeOnSignOut JSDoc to describe the actual fallback
behavior.
@brionmario
brionmario merged commit 76fc649 into thunder-id:main Aug 12, 2026
4 of 5 checks passed
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.

3 participants