Skip to content

feat(auth): register StrategyAuthGuard globally & consolidate auth flow#18

Open
NteinPrecious wants to merge 1 commit into
SourceXXL:mainfrom
NteinPrecious:feat/auth-strategy-consolidation
Open

feat(auth): register StrategyAuthGuard globally & consolidate auth flow#18
NteinPrecious wants to merge 1 commit into
SourceXXL:mainfrom
NteinPrecious:feat/auth-strategy-consolidation

Conversation

@NteinPrecious

Copy link
Copy Markdown

Summary

Closes #8

  • Global StrategyAuthGuard: StrategyAuthGuard is now registered as the first APP_GUARD in AppModule, so every route is protected by default via the pluggable strategy system (wallet, traditional, OAuth, API-key). No more per-controller @UseGuards(JwtAuthGuard) needed for new routes.
  • @Public() on open endpoints: GET /health and GET /info in AppController are decorated with @Public() so they remain unauthenticated. StrategyAuthGuard already reads IS_PUBLIC_KEY via Reflector to skip those routes.
  • TokenBlacklistService injection verified: TokenBlacklistService is already exported from AuthModule and injected into AuthService.logout() (which calls tokenBlacklist.revoke(jti, exp)). EnhancedAuthService uses refresh-token table revocation; WalletAuthService has no logout path — no additional injection required.
  • Legacy AuthService deprecated: AuthService.register() and AuthService.login() now carry @deprecated JSDoc comments directing callers to EnhancedAuthService, which adds refresh-token rotation and 2FA.
  • Auth architecture documented: A JSDoc block above @Module() in auth.module.ts explains all three flows (legacy, enhanced, strategy) and their boundaries.
  • Build passes: npm run build compiles with zero errors.

Test plan

  • GET /health and GET /info return 200 without an Authorization header
  • Any other route (e.g. GET /protected) returns 401 without a valid Bearer token
  • A valid JWT issued by any registered strategy (wallet, traditional, etc.) grants access to protected routes
  • AuthService.register / AuthService.login show @deprecated in IDE tooling
  • npm run build passes cleanly

- Register StrategyAuthGuard as global APP_GUARD in AppModule (first in chain)
  so all routes are protected by default; open routes use @public() decorator
- Apply @public() to GET /health and GET /info in AppController
- Add JSDoc @deprecated to AuthService.register() and AuthService.login()
  directing callers to use EnhancedAuthService instead
- Add architecture overview JSDoc to AuthModule explaining legacy, enhanced,
  and strategy-pattern auth flows; documents TokenBlacklistService injection
- TokenBlacklistService already exported from AuthModule and injected into
  AuthService.logout() — no additional injection required
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.

Align core/auth Module — Token Blacklist Injection & Strategy Pattern Consolidation

2 participants