Add role-based access control for admin role management - #1044
Merged
Conversation
Add an admin-only endpoint to assign and revoke user roles, a description field on roles, and a clear 403 message when a caller lacks a required role. Role changes bump the user's token version to invalidate existing sessions. New users default to the mentee role. Closes MentoNest#977
|
@Vox-d-glitch 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! 🚀 |
# Conflicts: # backend/src/users/users.module.ts # backend/src/users/users.service.spec.ts
- 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. Rewrite both specs to exercise what's actually there instead of leaving them permanently red.
Contributor
|
Please resolve conflict |
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.
Adds the admin-facing pieces of RBAC on top of the existing roles table and guard:
POST /admin/users/:userId/rolesandDELETE /admin/users/:userId/roles/:role, guarded by@Roles(AuthRole.ADMIN)tokenVersionso existing sessions are invalidatedRolesGuardnow throws aForbiddenExceptionwith a clear message instead of a generic 403descriptioncolumn added torolesUsersService.createUserassigns the mentee role by default for new accountsCloses #977