Ahmad Fathallah
06/26/2025, 8:38 AMuser with role of seller, the seller role can edit listing resource.
let's say the above is already defined in the existing system.
so additional rules might be.
user id must be equal to the listing author
so the full rule will be
user can edit listing (existing system), user id must equal to listing author (cerbos)
oguzhan
apiVersion: api.cerbos.dev/v1
resourcePolicy:
version: default
resource: listing
rules:
- actions:
- edit
effect: EFFECT_ALLOW
roles:
- SELLER
condition:
match:
expr: R.attr.authorId == P.id
After doing the internal authz check, you could use one of our SDKs to do the secondary authz check with Cerbos.
JS SDK example exercising above policy
const allowed = await cerbos.isAllowed({
principal: {
id: "oguzhan",
roles: [
"SELLER",
],
attributes: {},
},
resource: {
kind: "listing",
id: "1",
attributes: {
authorId: "oguzhan",
},
},
action: "edit",
});
See the relevant playground: https://play.cerbos.dev/p/nlc685d0fcdFZoKCVTwoPDXdSujJBq73Ahmad Fathallah
06/26/2025, 9:17 AM