rolesAuthorization
function rolesAuthorization(options?): AuthorizationProvider;Defined in: src/authorization/roles.ts:94
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/links/authorization/roles";
// Built-in admin/editor/viewer policy:const authz = rolesAuthorization();
// Custom policy:const custom = rolesAuthorization({ policy: { marketing: ["link:read", "link:create", "link:update", "analytics:read"], tracker: ["conversion:track"], },});