Skip to content

fix(auth): give every JWT a unique jti so same-second sessions don't collide - #491

Merged
datvt243 merged 1 commit into
stagingfrom
fix/490-access-token-jti
Nov 18, 2026
Merged

datvt243 merged 1 commit into
stagingfrom
fix/490-access-token-jti

Conversation

@datvt243

Copy link
Copy Markdown
Owner

df91bcc fix(auth): give every JWT a unique jti so same-second sessions don't collide

Closes #490

…collide

Access tokens were signed with { _id } only, so two issued for one candidate in the same second were byte-identical and logging out one session blacklisted the other.

- src/utils/jwt.ts: jwtSign sets jwtid: crypto.randomUUID() on every token (access and refresh)
- src/auth/auth.service.ts, src/auth/auth.controller.ts: drop the hand-built refresh jti (jsonwebtoken rejects payload jti + jwtid) and the now-unused crypto import
- tests: new src/__tests__/utils/jwt.test.ts; integration test for two same-second logins where logout of one leaves the other at 200; caller unit tests and refreshTokenReuse helper adjusted
- .claude/rules/api.md: auth flow payload now { _id, jti }
- agent-hub: ship note for auth-http-integration-tests

npm test: Test Suites: 75 passed, 75 total / Tests: 792 passed, 792 total
npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files

Node: fix-access-token-jti (SEALED)
Evidence: agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md

Closes #490

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@datvt243
datvt243 merged commit 74a49b8 into staging Nov 18, 2026
3 checks passed
@datvt243 datvt243 mentioned this pull request Nov 19, 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.

1 participant