Repository navigation
feat(auth): JWT key rotation with key ids and an overlap window - #242
Conversation
|
@Ezekiel146 CI is failing on this branch against the latest Backend (typecheck + test + build)
|
Access and refresh tokens are signed with the current key and carry its kid. Verification selects the key by kid and accepts a previous key during an overlap window, so rotation does not log users out. Tokens with an unknown kid are rejected. Adds the rotation runbook. Refs DocForum#106 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
@Ezekiel146 This PR now has merge conflicts with git fetch upstream # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-leaseThe usual culprits are shared docs like Automated message. It won't repeat unless the PR conflicts again after your next push. |
|
@Ezekiel146 The only CI failure on your latest run is the This PR also conflicts with git fetch upstream
git rebase upstream/main
# fix the conflicts, then
git push --force-with-lease |
8736bdf to
5dd753a
Compare
5dd753a to
f94c990
Compare
Keep both the keyring helpers and upstream's wallet-link cutoff parser in config. Adapt to upstream's `as const` config and @types/jsonwebtoken 9.0.10: type signWithKeyring's TTL as SignOptions['expiresIn'] and swap the keyring in the rotation test through a mutable view.
afeezorobsco-cyber
left a comment
There was a problem hiding this comment.
Sweep: malware scan clean, CI green.
afeezorobsco-cyber
left a comment
There was a problem hiding this comment.
Sweep: malware scan clean, CI green.
Closes #106
What changed
backend/src/config/index.ts: JWT signing keyrings for access and refresh tokens. The current key isJWT_*_SECRETwith an optionalJWT_*_KID. An optionalJWT_*_SECRET_PREVIOUSstays in the keyring during the overlap window.backend/src/modules/auth/services/tokens.ts: sign with the current key and write itskidinto the token header. Verify with the key named by the header'skid. Tokens with an unknownkidare rejected. Tokens without akid(issued before this change) are tried against each key.backend/tests/unit/tokens.test.ts: rotation tests. A new token records the currentkid. A previous-key token verifies during the overlap window and fails after the key is removed. An unknownkidis rejected. A legacy token still verifies.docs/runbooks/secret-rotation.md: the rotation procedure and the env var table.changelog.d/106-jwt-key-rotation.md.Which ROADMAP.md item does this close/progress?
Phase 9, issue #106 (production secrets management and key rotation). The rotation logic and the runbook are done. Still open: loading secrets from a secrets manager (depends on the platform choice in #22), the who-can-read-what section of the runbook, and the staging rotation record.
Docs updated in this PR
changelog.d/entry anddocs/runbooks/secret-rotation.mdaddedValidation
npm run testinbackend/before merging.🤖 Generated with Claude Code