A robust permission management system for Sophra’s admin API endpoints
Authentication and Authorization Flow
Invalid Token Format
getTokenPurpose
function returns null
, resulting in a permission denial.Unknown Endpoint
endpointPermissions
map are automatically denied, preventing access to potentially sensitive or unintended routes.Insufficient Permissions
hasPermission
returns false
, triggering a 403 Forbidden response from the API gateway.endpointPermissions
map allows for O(1) lookup timeisValidPurpose
function ensures that only predefined purposes are accepted, preventing arbitrary purpose injection.isSuperAdmin
function allows for special handling of high-privilege tokens, enabling additional security measures or auditing.