Repository navigation
fix(token-vault): reliably end the AM SSO session on logout (SDKS-5448) - #595
Conversation
🦋 Changeset detectedLatest commit: 11ac633 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit 11ac633
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #595 +/- ##
============================================
- Coverage 56.72% 27.24% -29.48%
============================================
Files 105 11 -94
Lines 28457 1567 -26890
Branches 1644 49 -1595
============================================
- Hits 16143 427 -15716
+ Misses 12314 1140 -11174 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3a20558 to
718aef5
Compare
ryanbas21
left a comment
There was a problem hiding this comment.
Approving solution 2, i'm assuming we will drop commit 1?
Summary
The token vault app's logout did not actually end the user's AM SSO session. The user appeared logged out, but the AM session survived — the next login silently re-authenticated via
prompt=nonewith no login form.Root cause
In the vault environment,
FRUser.logout()(default path) firesendSessionlast — afterTokenManager.deleteTokens()has already emptied the vault's token storage viaTVP_REMOVE_TOKENS. The vault's endSession branch staplesid_token_hintfrom its own storage, so by the time endSession fires, the only copy of the hint is gone → AM returns 400 and the SSO session survives.Meanwhile the
sessions?_action=logoutleg is a page-direct fetch with no service-worker route, so with 5823 removed from AM's CORS policy (the mitigation for the third token-vault vulnerability), it is refused preflight and never reaches AM.Two solutions
Solution A — fix the app (commit 1): Reorder logout: end the SSO session first, while the vault still holds the idToken, then revoke the grant, then clear vault storage:
No vault library changes needed — the existing endSession, revoke, and remove branches in the proxy already handle this correctly when called in the right order.
Solution B — fix the vault (commit 2): Route the AM session logout through the vault so stock
FRUser.logout()works as-is:generateAmUrlsnow includes the AMsessionsendpoint URL…/json/…/sessions/*sessionsbranch that relays_action=logoutto AM withcredentials: 'include', so the SSO cookie authenticates it (runs before the tokens-required gate, as it needs no tokens)With this,
FRUser.logout()'s first leg (session kill) succeeds through the vault; its trailing endSession 400s harmlessly on an already-dead session, and revoke + cleanup proceed as before.Deploying either solution alone produces a complete logout; both together are also fine.
Testing
Verified against a live AM tenant:
Solution A (before commit 2):
Solution B (commit 2, live probe through the vault proxy):
POST …/json/realms/root/realms/alpha/sessions/?_action=logoutrelayed through the vault with a live session → 200 "Successfully logged out"🤖 Generated with Claude Code