Repository navigation
Conversation
Blacklist keys are now a SHA-256 of the token; legacy raw keys are still honored until they expire. Signed-off-by: John Bair <john.bair@swirldslabs.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3795 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 224 224
Lines 7034 7034
Branches 1302 1276 -26
=======================================
Hits 7033 7033
Misses 1 1 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical rolling-deployment compatibility issue remains: old instances read only raw blacklist keys while new instances write only hashed keys, allowing blacklisted tokens to remain accepted.
1 open issue
What changed in this PR
Updates JWT blacklist storage to use SHA-256 token fingerprints instead of raw JWT Redis keys while retaining temporary compatibility with legacy entries.
Changes:
- Stores newly blacklisted tokens under hashed fingerprint keys.
- Checks hashed and legacy raw-token keys during migration.
- Expands unit tests for hashing, compatibility lookups, and Redis errors.
| File | Description |
|---|---|
| back-end/libs/common/src/blacklist/blacklist.service.ts | Implements hashed JWT blacklist keys and temporary legacy raw-key lookup support. |
| back-end/libs/common/src/blacklist/blacklist.service.spec.ts | Tests hashed storage, legacy compatibility lookups, and Redis failure handling. |
Review effort: Lite
| async blacklistToken(jwt: string | null) { | ||
| if (jwt !== null) { | ||
| await this.client.set(jwt, this.BLACKLISTED, 'EX', this.getJwtExpirationSeconds()); | ||
| await this.client.set(this.getTokenKey(jwt), this.BLACKLISTED, 'EX', this.getJwtExpirationSeconds()); |
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.

The blacklist now keys on a SHA-256 fingerprint of the token instead of the raw JWT, matching how OTP codes are hashed. Legacy raw-key entries are still checked until they expire, with a TODO to remove that lookup.
Fixes #3794
Fixes TT-019