rolesAuthorization
function rolesAuthorization(options?): AuthorizationProvider;Defined in: src/authorization/roles.ts:96
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/webhooks/authorization/roles";
// Built-in admin/editor/viewer policy:const authz = rolesAuthorization();
// Custom policy:const custom = rolesAuthorization({ policy: { ops: ["delivery:read", "delivery:retry", "endpoint:read"], auditor: ["audit:read"], },});