Skip to content

Latest commit

 

History

History
87 lines (48 loc) · 1.08 KB

core.client.isallowed.md

File metadata and controls

87 lines (48 loc) · 1.08 KB

Home > @cerbos/core > Client > isAllowed

Client.isAllowed() method

Check if a principal is allowed to perform an action on a resource.

Signature:

isAllowed(request: IsAllowedRequest, options?: RequestOptions): Promise<boolean>;

Parameters

Parameter

Type

Description

request

IsAllowedRequest

options

RequestOptions

(Optional)

Returns:

Promise<boolean>

Example

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