Skip to content

Detect if rule exists and run it #597

Discussion options

You must be logged in to vote

There is no assertion attribute on the admin role. This makes the assertions[p.assertion] statement fail, as p.assertion is undefined. You can solve this a number of ways; like adding an assertion to the admin role that is always true, or by wrapping the assertions[*] call in a function that handles this scenario.

E.g.;

assert(p) if {
	not p.assertion
} else if {
	assertions[p.assertion]
}

and then call assert(p) in your allow rule.

https://play.openpolicyagent.org/p/E0WY4deUGc

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@chippyash
Comment options

@johanfylling
Comment options

Answer selected by chippyash
@chippyash
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants