delegatedAuthorization
function delegatedAuthorization(options): AuthorizationProvider;Defined in: src/authorization/delegated.ts:43
Create an AuthorizationProvider from a plain decision function.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
DelegatedAuthorizationOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { delegatedAuthorization } from "@xtandard/entitlements/authorization/delegated";
const authz = delegatedAuthorization({ // Support staff may only touch the customers of their own region. authorize: ({ principal, resource }) => !("customer" in resource) || resource.customer === undefined || (principal?.metadata as { customers?: string[] } | undefined)?.customers?.includes( resource.customer, ) === true,});