Derived roles
Traditional RBAC roles are usually broad groupings with no context awareness. They are static and they are provided by the Identity Provider(IDP), not by Cerbos. Cerbos provides derived roles as a way of augmenting those broad roles with contextual data to provide more fine-grained control at runtime. For example, a person with the broad manager
role can be augmented to manager_of_scranton_branch
by taking into account the geographic location (or another factor) and giving that derived role bearer extra privileges on resources that belong to the Scranton branch.
Derived roles are dynamically determined at runtime by matching the principal’s roles sent in the API request to the parentRoles specified in the derived roles definitions. Don’t use the derived role names as roles in the API request as Cerbos only expects that field to contain "normal" roles.
|
---
apiVersion: "api.cerbos.dev/v1"
description: |-
Common dynamic roles used within the Apatr app
derivedRoles:
name: apatr_common_roles (1)
variables:
import: (2)
- apatr_common_variables
local: (3)
flagged_resource: request.resource.attr.flagged
definitions:
- name: owner (4)
parentRoles: ["user"] (5)
condition: (6)
match:
expr: request.resource.attr.owner == request.principal.id
- name: abuse_moderator
parentRoles: ["moderator"]
condition:
match:
expr: V.flagged_resource == true
1 | Name to use when importing this set of derived roles. |
2 | Variable definitions to import (optional). |
3 | Local variable definitions (optional). |
4 | Descriptive name for this derived role. |
5 | The static roles (from the identity provider) to which this derived role applies to. The special value * can be used to match any role. |
6 | An (optional) set of expressions that should evaluate to true for this role to activate. |