Skip to content

[Backend] Role-Based Control Guards for Route Scopes#312

Open
armorbreak001 wants to merge 1 commit intoGalactiGuild:mainfrom
armorbreak001:bounty/296-role-guards
Open

[Backend] Role-Based Control Guards for Route Scopes#312
armorbreak001 wants to merge 1 commit intoGalactiGuild:mainfrom
armorbreak001:bounty/296-role-guards

Conversation

@armorbreak001
Copy link
Copy Markdown

Fixes #296

Changes

  • BountyController: Applied RoleGuard + @Roles(...) to all mutating endpoints:
    • PATCH /bounties/:id (update) → ADMIN only
    • POST /bounties/:id/cancelADMIN only
    • POST /bounties/:id/review-workADMIN only
    • POST /bounties/:id/applications/:appId/reviewADMIN or MODERATOR
    • POST /bounties/:id/milestones/:mid/approveADMIN or MODERATOR
  • Non-admin/moderator users receive standard NestJS 403 Forbidden response
  • Read endpoints (GET, create, apply, submit-work) remain open to any authenticated user

Acceptance Criteria Met

  • Develop @Roles(...roles) decorator assigning acceptable criteria array strings (already existed — now applied)
  • Develop RolesGuard examining ExecutionCtx payload reflecting User roles (already existed — now applied)
  • Add explicit block restricting /bounties/:id mutating patches exclusively to ADMIN (and MODERATOR for review endpoints)
  • Expose standard 403 Forbidden exception payload

How to Verify

  1. Register two users: one as USER, one as ADMIN
  2. Call PATCH /bounties/:id with USER token → 403 Forbidden
  3. Call PATCH /bounties/:id with ADMIN token → success
  4. Same pattern applies to cancel, review-work, approve milestones

- Import RoleGuard, Roles decorator, UserRole into BountyController
- PATCH /bounties/:id (update) → ADMIN only
- POST /bounties/:id/cancel → ADMIN only
- POST /bounties/:id/review-work → ADMIN only
- POST /:id/applications/:appId/review → ADMIN or MODERATOR
- POST /:id/milestones/:mid/approve → ADMIN or MODERATOR
- Non-admin users receive 403 Forbidden on protected endpoints

Fixes GalactiGuild#296
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.

[Backend] Role-Based Control Guards for Route Scopes

1 participant