Title
#community
r

Rounak Datta

08/24/2022, 7:13 AM
Hello! I am writing a derived role where I want to store the parentRole (that the user is coming as) into a variable. This will help me simplify and templatize my conditional expressions. Is it currently supported in Cerbos CEL?
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

08/24/2022, 7:27 AM
There is support for variables in a policy https://docs.cerbos.dev/cerbos/latest/policies/conditions.html#_policy_variables Does this do what you need?
r

Rounak Datta

08/24/2022, 7:29 AM
Umm, the variable support in my use case is for derived roles actually 🙂 Looking for a similar construct like that in policy.
Charith (Cerbos)

Charith (Cerbos)

08/24/2022, 7:30 AM
You can access the set of roles using
request.principal.roles
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

08/24/2022, 7:30 AM
You can create variables in any type of file
r

Rounak Datta

08/24/2022, 7:31 AM
Interesting, let me try it out, thanks
2:09 PM
On the similar lines, like we define variables for fixed values, Can we define expressions into variables for re-usability? 😉
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

08/24/2022, 2:10 PM