Channels
announcements
help
community
Powered by
#community
Title
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?
a
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.
c
Charith (Cerbos)
08/24/2022, 7:30 AM
You can access the set of roles using
request.principal.roles
a
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
On the similar lines, like we define variables for fixed values, Can we define expressions into variables for re-usability? 😉
a
Alex Olivier (Cerbos)
08/24/2022, 2:10 PM
Yup! there is an example here
https://docs.cerbos.dev/cerbos/latest/policies/conditions.html#_policy_variables
4 Views
Post