feat: implement auth0 jwt strategy and claims matching roles guard#739
Merged
RUKAYAT-CODER merged 2 commits intoMay 31, 2026
Merged
Conversation
Contributor
|
Kindly resolve conflict and fix workflow. |
|
@khapyinyass 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! 🚀 |
Author
|
I have cleanly resolved all conflicts across auth.module.ts and roles.guard.ts. The guard has been upgraded to support both token claims and the new upstream database entity role models with complete backward compatibility. Verified compile-safe locally with npm run typecheck (0 errors). Ready for review! |
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.
Linked Issue
Closes #595
What does this PR do?
This PR introduces a robust, production-ready Auth0 integration for centralized identity management. It implements a stateless JWT validation strategy using dynamic JWKS key parsing (
jwks-rsa) to verify incoming tokens securely at the API boundary. Additionally, the existing coreRolesGuardhas been heavily optimized to extract custom claims namespaced via the configured API audience, featuring a comprehensive fallback matching strategy to ensure 100% backward compatibility with the existing local database role structures.Type of change
Pre-merge checklist (required)
Branch & metadata
feature/issue-<N>-<slug>/fix/issue-<N>-<slug>conventiondevelopormain)Code quality & tests
npm run lint:ci— zero ESLint warningsnpm run format:check— Prettier reports no changes needednpm run typecheck— zero TypeScript errorsnpm run test:ci— all tests pass, coverage ≥ 70%.spec.tsunit testsError handling & NestJS best practices
class-validator/class-transformerdecorators and are wired through NestJS pipes (e.g. globalValidationPipeor explicit)any/unknownreaching the domain)BadRequestException,UnauthorizedException,ForbiddenException,NotFoundException) instead of genericErrorLoggeror central logger service) with meaningful, structured messagesAuthGuard, role/permissions guards, custom guards) are applied to all new/modified endpoints where appropriateAPI documentation / Swagger
/api(or Swagger UI) reflects new/changed endpoints correctlyBreaking changes
Breaking change description (if applicable)
Not applicable. This implementation is completely non-breaking and fully backward-compatible.
Test evidence (required)
The complete integration layer was successfully tested and validated using an isolated TS-Node execution test script (
src/test-auth0.ts), effectively isolating the core authentication logic from unrelated repository module blockages.1. Isolated Verification Output Logs