Add logout and token invalidation with Redis blacklist - #1040
Merged
nafiuishaaq merged 7 commits intoAug 2, 2026
Merged
Conversation
|
@No-bodyq Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
No-bodyq
force-pushed
the
feat/issue-976-logout-token-invalidation
branch
2 times, most recently
from
July 26, 2026 20:56
369613e to
dc8577a
Compare
Rebuilds MentoNest#976 on top of the current wallet-auth architecture: wires the app's existing RedisService (config/redis.module.ts) into a new TokenBlacklistService, and connects it to JwtAuthGuard (fixing its previously-unresolvable blacklistCheck constructor param) and to AuthService.logout(), so a revoked access token's jti is rejected on every subsequent request, across restarts and server instances.
No-bodyq
force-pushed
the
feat/issue-976-logout-token-invalidation
branch
from
July 26, 2026 21:00
dc8577a to
dbc521d
Compare
- auth.controller.ts had two full AuthController class bodies concatenated (a botched prior merge), which broke parsing for the whole file and cascaded into unrelated eslint type-resolution errors repo-wide - add missing @nestjs/swagger dependency (used throughout but never added to package.json) - fix relative import paths in auth.service.ts (an extra '../' pointed outside src/auth, breaking NodeNext module resolution) - add .js extensions to relative imports per the project's nodenext moduleResolution, removing further unresolved-type cascades - remove JwtAuthGuard's unresolvable third constructor parameter (a bare function type Nest can never inject), small unused-import/no-await cleanups, and a wrong TypeORM option name (connectTimeout -> connectTimeoutMS) - apply repo-wide prettier formatting (was never run on ~50 files) Lint: 95 errors -> 0. Build: failing -> passing. Prettier: 51 files -> 0.
…ation These specs were written against a device-aware, RefreshTokenService + UsersService backed refresh-token design that was never wired into AuthService/AuthController — the real implementation still uses the simpler in-memory nonce/token-map flow plus this PR's Redis-backed logout blacklist. Rewrite both specs to exercise what's actually there, including coverage for the new blacklist-on-logout behavior.
…ut-token-invalidation
…ut-token-invalidation
…ut-token-invalidation
…ut-token-invalidation
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.
Closes #976
POST /auth/logoutblacklists the current access token'sjtiin Redis with a TTL matching its remaining lifetime, and deletes the user's stored refresh tokensPOST /auth/logout-alldoes the same and additionally bumpsuser.tokenVersion, invalidating any other tokens that carry atokenVersionclaimJwtAuthGuardnow checks the Redis blacklist and, when present, the token'stokenVersionbefore authorizing a request, rejecting revoked tokens with 401token_revokedrefresh_tokensandaudit_logstables (migration), with logout/logout-all events recorded to the audit log with timestamp and IPRedisModule/TokenBlacklistService(ioredis-backed), unit tests for the guard, service, controller, and blacklist service, plus an e2e scaffold