Skip to content

Feat/refresh token reuse detection - #15

Merged
Yentec merged 7 commits into
mainfrom
feat/refresh-token-reuse-detection
Jun 12, 2026
Merged

Feat/refresh token reuse detection#15
Yentec merged 7 commits into
mainfrom
feat/refresh-token-reuse-detection

Conversation

@Yentec

@Yentec Yentec commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Description

Refresh token reuse detection via chain revocation

Changes

  • Added chainId (UUID) column + index to refresh_tokens with a two-step migration (temporary DEFAULT gen_random_uuid() for existing rows, then dropped)
  • Updated createRefreshToken to accept chainId, added revokeChain method using a single updateMany (no loop)
  • Split reuse detection from expiry check in refresh() — replayed token triggers revokeChain + logger.warn audit log before 401
    issueTokens generates a new chainId on login/register, preserves it on rotation
  • Created docs/adr/0006-refresh-token-reuse-detection.md — documents the decision and the network-retry false-positive trade-off

Validation

  • 38/38 tests pass
  • Clean typecheck
  • Clean lint
  • Integration test: tokenA → tokenB → replay(tokenA) → 401 + tokenB révoqué par la chaîne → 401
  • Utilisateur doit se reconnecter après détection d'un replay

Closes #10

@Yentec
Yentec merged commit cb5a73b into main Jun 12, 2026
2 checks passed
@Yentec
Yentec deleted the feat/refresh-token-reuse-detection branch June 12, 2026 09:36
@Yentec Yentec mentioned this pull request Jun 15, 2026
5 tasks
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.

Refresh token reuse detection

1 participant