Skip to content

rolesAuthorization

function rolesAuthorization(options?): AuthorizationProvider;

Defined in: src/authorization/roles.ts:125

Create a role-based AuthorizationProvider.

Decision order:

  1. If readonly and the action mutates → deny.
  2. If the principal is null → deny.
  3. If any of the principal’s roles grants the action (via "*" or an explicit list) → allow; otherwise deny.
Parameter Type
options? RolesAuthorizationOptions

AuthorizationProvider

import { rolesAuthorization } from "@xtandard/entitlements/authorization/roles";
// Built-in viewer / support / billing-admin / admin / runtime-service policy:
const authz = rolesAuthorization();
// Custom policy:
const custom = rolesAuthorization({
policy: {
success: ["customer:read", "usage:read", "grant:write"],
auditor: ["activity:read"],
},
});