Skip to content

Auth middleware + role-based access control (RBAC) #3

Description

@Martins0152

Description
Build the authenticate middleware (verifies JWT, attaches req.user) and a requireRole(...) middleware for RBAC, matching the four roles in the schema (ADMIN, ORGANIZATION, DONOR, BENEFICIARY).

Acceptance Criteria

  • Missing/invalid/expired token returns 401 with a clear error message.
  • requireRole returns 403 when the authenticated user's role isn't permitted.
  • Middleware is unit tested for all four roles plus the unauthenticated case.
  • At least one existing or stub route demonstrates the middleware in use.
  • Documented in openapi.yaml via security: [{bearerAuth: []}] on the protected route(s).

Suggested reward: $20-$30

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authAuthentication/authorizationbackendBackend/API workmediumModerate complexity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions