Skip to content

Latest commit

 

History

History
88 lines (49 loc) · 1.21 KB

core.client.checkresource.md

File metadata and controls

88 lines (49 loc) · 1.21 KB

Home > @cerbos/core > Client > checkResource

Client.checkResource() method

Check a principal's permissions on a resource.

Signature:

checkResource(request: CheckResourceRequest, options?: RequestOptions): Promise<CheckResourcesResult>;

Parameters

Parameter

Type

Description

request

CheckResourceRequest

options

RequestOptions

(Optional)

**Returns:**

Promise<CheckResourcesResult>

Example

const decision = await cerbos.checkResource({
  principal: {
    id: "[email protected]",
    roles: ["USER"],
    attr: { tier: "PREMIUM" },
  },
  resource: {
    kind: "document",
    id: "1",
    attr: { owner: "[email protected]" },
  },
  actions: ["view", "edit"],
});

decision.isAllowed("view"); // => true