You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, both arguments to object.subset must be of the same type. This makes sense, but there's one exception I think should be allowed. If the superset is an array, the subset should be allowed to be a set, meaning "if all items in sub are in super, with no consideration of ordering". This is a IMHO a nice construct:
allow if object.subset(input.user.roles, {"developer", "logs-reader"})
You can of course achieve this today by first converting input.user.roles to a set, but if we can remove an extra step for the likely most common operation, let's do it.
For anyone who wants to work on this, these are the steps I imagine would be needed:
Allow first argument provided to be of type array, and the second argument to be of type set.
Add a few test cases to assert this works as described above.
Add support for checking if `super` array contains
every element of `sub` set to object.subset.
object.subset allows `super` to be array and `sub` to be set.
Fixes: open-policy-agent#4858
Signed-off-by: x-color <36035885+x-color@users.noreply.github.com>
Add support for checking if `super` array contains
every element of `sub` set to object.subset.
object.subset allows `super` to be array and `sub` to be set.
Fixes: #4858
Signed-off-by: x-color <36035885+x-color@users.noreply.github.com>
Currently, both arguments to
object.subset
must be of the same type. This makes sense, but there's one exception I think should be allowed. If the superset is an array, the subset should be allowed to be a set, meaning "if all items in sub are in super, with no consideration of ordering". This is a IMHO a nice construct:You can of course achieve this today by first converting
input.user.roles
to a set, but if we can remove an extra step for the likely most common operation, let's do it.For anyone who wants to work on this, these are the steps I imagine would be needed:
Join the #development channel on the OPA Slack if you'd like to discuss the approach while working on this.
The text was updated successfully, but these errors were encountered: