Home > @cerbos/core > Client > checkResource
Check a principal's permissions on a resource.
Signature:
checkResource(request: CheckResourceRequest, options?: RequestOptions): Promise<CheckResourcesResult>;
Parameter |
Type |
Description |
---|---|---|
request | ||
options |
(Optional) |
Promise<CheckResourcesResult>
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