Service Layer medium complexity backend
2
Dependencies
11
Dependents
12
Entities
0
Integrations

Description

Backend middleware that reads the role claim array from the validated JWT access token on every protected request and rejects calls from roles not permitted to reach that endpoint. No role check is delegated to the application layer.

Feature: Role-Based Access Control

route-guard-service

Responsibilities

  • Extract and validate role claims from the JWT bearer token on every protected endpoint
  • Return 403 Forbidden with a structured error body for insufficient role
  • Enforce tenant scoping so Global Admins cannot reach organization operational data by default
  • Gate module-level endpoints against the organization's enabled module set

Interfaces

requireRole(allowedRoles: Role[]): Middleware
requireModuleEnabled(moduleId: string): Middleware
extractRoleClaims(token: string): Role[]