-
Notifications
You must be signed in to change notification settings - Fork 173
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
ListUsers
intersection
#1467
ListUsers
intersection
#1467
Conversation
…DXAZC-1924-listusers-intersection-exclusionB
…listusers-intersection
…penfga into listusers-intersection
@@ -857,8 +857,7 @@ func TestListUsersIntersection(t *testing.T) { | |||
}) | |||
tests := ListUsersTests{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized after merging this that there is one unit test worth adding, and it's currently failing:
{
name: "intersection_and_wildcard",
req: &openfgav1.ListUsersRequest{
Object: &openfgav1.Object{Type: "document", Id: "1"},
Relation: "can_view",
UserFilters: []*openfgav1.ListUsersFilter{
{
Type: "user",
},
},
},
model: `model
schema 1.1
type user
type document
relations
define allowed: [user]
define viewer: [user:*] and allowed
define can_view: viewer`,
tuples: []*openfgav1.TupleKey{
tuple.NewTupleKey("document:1", "allowed", "user:jon"),
tuple.NewTupleKey("document:1", "viewer", "user:*"),
tuple.NewTupleKey("document:2", "viewer", "user:*"),
},
expectedUsers: []string{"user:jon"},
},
For reference, this appears in https://github.com/openfga/openfga/blob/main/assets/tests/consolidated_1_1_tests.yaml#L4595-L4659
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point! Addressed in #1485.
Description
Adding support for intersection rewrites in
ListUsers
via theand
operator.To achieve this, we need to execute the expand against all children of the intersection rewrite. We then aggregate the frequency count of all of the returned users. If that count is equal to the number of children, that indicates that the user was present in all intersection rewrite expands, thus we push it onto the main results channel.
This work may need to be refactored slightly when exclusion is introduced.
References
Parent PR: #1428
Review Checklist
main