Joe Cantwell
10/14/2024, 3:54 PMapiVersion: "api.cerbos.dev/v1"
description: |-
Permissions based roles
derivedRoles:
name: line_ip_roles
definitions:
- name: viewer
parentRoles: ["user"]
condition:
match:
all:
of:
- expr: ...
- name: reader
parentRoles: ["viewer"]
condition:
match:
all:
of:
- expr: ...
- name: editor
parentRoles: ["reader"]
condition:
match:
expr: ...
---
apiVersion: api.cerbos.dev/v1
resourcePolicy:
version: "default"
resource: "line:ip"
rules:
- actions:
- view
effect: EFFECT_ALLOW
roles:
- viewer
- actions:
- read
effect: EFFECT_ALLOW
roles:
- reader
- actions:
- edit
effect: EFFECT_ALLOW
roles:
- editor
so if my test principal has the reader
role, I would have thought he’d also have the viewer
role but that doesn’t seem to be the case. Is this not supported or am I just doing something daft?Sam Lock (Cerbos)
10/14/2024, 4:05 PMderivedRoles
rather than roles
). This allows you to namespace derived role definitions (and reuse derived role names, etc).
You can see an example of this in the resource policy example in the docs; namely, the annotations 4
(import statement) and 8
(the rule/derived role mapping).Sam Lock (Cerbos)
10/14/2024, 4:07 PMimport
name maps to the name
field defined in the derived role policy (annotation 1
in the derived role example)Joe Cantwell
10/14/2024, 4:09 PMJoe Cantwell
10/18/2024, 2:58 PMSam Lock (Cerbos)
10/21/2024, 2:47 PMJoe Cantwell
10/21/2024, 3:23 PMviewer
role, I could inherit the rules applied and extend through a further derived editor
role or similar.