Repository navigation
fix: drop sessions carrying an expired access token - #16
Merged
Merged
Conversation
Collaborator
Author
|
CI here fails only on the audit step — advisories pre-dating this branch (main fails identically). #17 clears them; update this branch after it merges and CI should go green. |
cuzzlor
force-pushed
the
fix/expired-session-token-wedge
branch
from
August 15, 2026 09:43
13112ba to
cc1477e
Compare
mderriey
approved these changes
Aug 16, 2026
cuzzlor
added a commit
that referenced
this pull request
Aug 16, 2026
`npm audit fix` resolves 23 of the 24 advisories accumulated since the last release (vite, shell-quote, qs, fast-uri, launch-editor, etc. — all transitive devDependencies; nothing shipped changes). The remaining low-severity advisory (GHSA-g7r4-m6w7-qqqr, esbuild 0.27.3–0.28.0 dev-server file read on Windows) has no in-range fix via tsx/vite yet, so it gets an .nsprc exception with removal notes — esbuild is only used here as a build/test transform, never as a dev server. The stale uuid exception (fixed by the update) is removed. Unblocks CI for #15 and #16, which fail on the audit step for advisories predating those branches. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The session cookie can outlive the access token it stores. When that happens, copySessionJwtToBearerHeader keeps copying the expired token to the authorization header, where it fails bearer verification on the resource server — while its presence suppresses the interactive re-login redirect apps typically gate on the header being absent. The browser is wedged on 401s until the cookie expires or the user manually logs out. Decode the token's exp claim (no signature verification — that remains the resource server's job) and, when it has expired, drop the session and skip the copy so the login middleware re-runs on the same request. Unparsable tokens still pass through untouched for downstream bearer verification to judge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Releases the login-handler crash fix and the expired-session fix together. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cuzzlor
force-pushed
the
fix/expired-session-token-wedge
branch
from
August 16, 2026 09:59
cc1477e to
e687e7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The session cookie can outlive the access token it stores (e.g. a 1h cookie holding a token Entra issued with a shorter lifetime, or any visit after token expiry but before cookie expiry). When that happens:
copySessionJwtToBearerHeaderkeeps copying the expired token to theauthorizationheader, where it fails bearer verification on the resource server → 401/FORBIDDEN.The browser is wedged on 401s until the cookie expires or the user manually logs out.
Fix
Decode the token's
expclaim — plain base64 payload decode, no signature verification, which remains the resource server's job — and when it has expired, drop the session (req.session = null) and skip the copy. The login middleware then re-runs on the same request, giving the user a transparent SSO redirect instead of a dead end. Unparsable tokens still pass through untouched for downstream bearer verification to judge, exactly as before.Also bumps the package version to 2.1.0 as the top of the stack.
Testing
Added
src/copy-session-jwt-to-bearer-header.spec.ts:authorizationheader and unauthenticated sessions untouchednpm run lint,npm run check-types, andnpm testall pass, plusnpm run buildandnpm run auditon the assembled stack.🤖 Generated with Claude Code