Home > @cerbos/core > Client > isAllowed
Check if a principal is allowed to perform an action on a resource.
Signature:
isAllowed(request: IsAllowedRequest, options?: RequestOptions): Promise<boolean>;
Parameter |
Type |
Description |
---|---|---|
request | ||
options |
(Optional) |
Returns:
Promise<boolean>
await cerbos.isAllowed({
principal: {
id: "user@example.com",
roles: ["USER"],
attr: { tier: "PREMIUM" },
},
resource: {
kind: "document",
id: "1",
attr: { owner: "user@example.com" },
},
action: "view",
}); // => true