Clint
11/14/2025, 10:43 AMClint
11/14/2025, 10:45 AMapiVersion: api.cerbos.dev/v1
derivedRoles:
name: business_roles
definitions:
- name: ROLE_Financial_Controlling
parentRoles:
- user
condition:
match:
expr: P.attr.department in ["LIVX2", "FIN01", "FIN07"]
- name: ROLE_Legal_Counsel
parentRoles:
- user
condition:
match:
expr: P.attr.department in ["LEG01", "LEG02", "COMPLIANCE_A"]
- name: ROLE_Export_Control
parentRoles:
- user
condition:
match:
expr: P.attr.department in ["EXP01", "TRADE_C"]
data_labels.yaml
apiVersion: api.cerbos.dev/v1
derivedRoles:
name: data_labels
definitions:
- name: LABEL_Financial_Controlling
parentRoles: ["ROLE_Financial_Controlling"]
- name: LABEL_Business_Controlling
parentRoles: ["ROLE_Business_Controlling"]
- name: LABEL_GDPR
parentRoles: ["ROLE_Legal_Counsel", "ROLE_HR_Operations"]
- name: LABEL_Export_Control
parentRoles: ["ROLE_Export_Control", "ROLE_Logistics_Operations"]
- name: LABEL_Legal
parentRoles: ["ROLE_Legal_Counsel"]
- name: LABEL_Sensitive
parentRoles: ["ROLE_Financial_Controlling", "ROLE_Legal_Counsel"]
geo_labels.yaml
apiVersion: api.cerbos.dev/v1
derivedRoles:
name: geo_labels
definitions:
- name: LABEL_US
parentRoles:
- user
condition:
match:
expr: P.attr.geography == "US"
- name: LABEL_EMEA
parentRoles:
- user
condition:
match:
expr: P.attr.geography == "EMEA"
- name: LABEL_Asia
parentRoles:
- user
condition:
match:
expr: P.attr.geography == "Asia"
- name: LABEL_China
parentRoles:
- user
condition:
match:
expr: P.attr.geography == "China"
label_aggregator.yaml
apiVersion: api.cerbos.dev/v1
resourcePolicy:
version: "default"
resource: "label_aggregator"
importDerivedRoles:
- geo_labels
- business_roles
- data_labels
rules:
- actions:
- get_labels
effect: EFFECT_ALLOW
roles:
- user
output:
expr: |
{
"computed_labels": P.roles
.filter(r, r.startsWith("LABEL_"))
.map(r, r.replace("LABEL_", "")),
"user_id": P.id,
"geography": P.attr.geography,
"legal_entity": P.attr.legal_entity,
"department": P.attr.department
}
priciple_1
{
"id": "smith_john",
"roles": [
"user"
],
"attr": {
"geography": "US",
"legal_entity": "LG101757",
"department": "LIVX2"
}
}oguzhan
P.roles doesn't include the effective derived roles for the principal because we do not mutate the incoming request. Instead we add the information to the runtime object. In this case you could use runtime.effectiveDerivedRoles.
2. The resource policy rule should have derivedRoles instead of `roles`:
...
- actions:
- get_labels
effect: EFFECT_ALLOW
derivedRoles:
- LABEL_US
- LABEL_EMEA
- LABEL_Asia
- LABEL_China
...Clint
11/14/2025, 12:19 PMCharith (Cerbos)
Check request to make sure that those conditions are satisfied for a given user and an invoice.Clint
11/14/2025, 1:27 PMCharith (Cerbos)