rolesAuthorization
function rolesAuthorization(options?): AuthorizationProvider;Defined in: src/authorization/roles.ts:99
Create a role-based AuthorizationProvider.
Decision order:
- If
readonlyand the action mutates → deny. - If the principal is
null→ deny. - If any of the principal’s roles grants the action (via
"*"or an explicit list) → allow; otherwise deny.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
RolesAuthorizationOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { rolesAuthorization } from "@xtandard/audit/authorization/roles";
// Built-in admin/auditor/viewer policy:const authz = rolesAuthorization();
// Custom policy:const custom = rolesAuthorization({ policy: { support: ["tenant:read", "event:read"], compliance: ["event:read", "event:export", "event:erase"], },});