Home > @cerbos/core > Client > checkResources
Check a principal's permissions on a set of resources.
Signature:
checkResources(request: CheckResourcesRequest, options?: RequestOptions): Promise<CheckResourcesResponse>;
Parameter |
Type |
Description |
---|---|---|
request | ||
options |
(Optional) |
Promise<CheckResourcesResponse>
const decision = await cerbos.checkResources({
principal: {
id: "[email protected]",
roles: ["USER"],
attr: { tier: "PREMIUM" },
},
resources: [
{
resource: {
kind: "document",
id: "1",
attr: { owner: "[email protected]" },
},
actions: ["view", "edit"],
},
{
resource: {
kind: "image",
id: "1",
attr: { owner: "[email protected]" },
},
actions: ["delete"],
},
],
});
decision.isAllowed({
resource: { kind: "document", id: "1" },
action: "view",
}); // => true