-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to express "no matching predicates"? #169
Comments
about negative matchingcurrently, there is one way to assert the absence of a fact, the An upcoming feature is something equivalent is for your caseI would generate different facts based on whether the object has a restriction on groups // generated based on the object being accessed
object("owner"); // no group restriction
object("owner", ["groups"]); // group restrictions
// generated based on the user info
user("user id",["user groups"]); and in the authorizer: check if user($user, $user_groups), object($user)
or user($user, $user_groups), object($user, $object_groups), $object_groups.intersection($user_groups).length() > 0; |
Thanks! That will work for me. With the
Then if we didn't define an |
yeah, relying on deny policies is a bit more risky indeed. From what I understood of your case, putting group info in the same fact as the user id seems to be the simplest way to go |
Quite possibly there's a way to do what I want, but haven't been able to figure it out. I'm gating access to some object, based on data in that object. Normally the policy just checks for simple ownership:
Authority:
Authorizer:
However, sometimes there's an extra field on the content (say, a group) and the user needs to also be a member of that if present. So you could write the authorizer like:
I could dynamically add the
check
depending on the object properties, but if I'm going to have some random code doing that I might as well just check it directly; my hope is that the authorizer is static and the source of truth for the rules. There are a lot of different cases here and I was hoping to have a single Authorizer file for each.So, I'm struggling to write policies that can selectively depend on certain facts. Conceptually what I want is something like:
Or, some way to construct a set out of all the terms in a fact, where "no match" results in an empty set.
The best solution I've found so far is to make the injected fact carry a set, ab empty set indicates a null/missing value, and this fact is always added to the Authorizer e.g:
Any thoughts?
The text was updated successfully, but these errors were encountered: