Skip to content
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 API #1433

Merged
merged 112 commits into from
May 29, 2024
Merged

ListUsers API #1433

merged 112 commits into from
May 29, 2024

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Mar 8, 2024

Description

Introducing the ListUsers API which answers the question "what users are related to a specific object?". To learn more about this feature, refer to the ListUsers RFC.

A ListUsers request is composed of three main properties:

  • user_filter – the type of user (subject) targeted for the response. This can either be a terminal type (e.g. user) or a userset (e.g. group#member). Only one user filter can be provided at this time.
  • relation – the target relation that subjects need to the specified object
  • object – the target resource that subjects need to be related to

Example:
Consider this model and tuples:

model
  schema 1.1

type user

type group
  relations
    define member: [user]

type document
  relations
    define viewer: [user, group#member]
    
#   document:1, viewer, user:maria
#   document:1, viewer, user:will
#   document:2, viewer, user:jon
#   group:A, member, user:christy
#   document:1, viewer, group:A#member

If we want to return all subjects of type user that have the viewer relation on document:1 we would call
ListUsers(user_filter=user, viewer, document:1) which would return the following:

{
    "users": [ "user:maria", "user:will", "user:christy" ]
    "excluded_users": []
}

Note: This API will initially be released in an experimental capacity. It can be enabled by setting OPENFGA_EXPERIMENTALS=enable-list-users

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@miparnisari miparnisari changed the title ListUsers API [DO NOT MERGE] ListUsers API Mar 11, 2024
@willvedd willvedd mentioned this pull request Mar 18, 2024
4 tasks
pkg/server/server_test.go Outdated Show resolved Hide resolved
pkg/server/server.go Outdated Show resolved Hide resolved
pkg/server/list_users.go Outdated Show resolved Hide resolved
pkg/server/list_users.go Outdated Show resolved Hide resolved
pkg/server/list_users.go Outdated Show resolved Hide resolved
pkg/server/list_users.go Outdated Show resolved Hide resolved
pkg/server/list_users.go Outdated Show resolved Hide resolved
pkg/server/list_users.go Outdated Show resolved Hide resolved
@willvedd
Copy link
Contributor Author

Not sure we should be treating this like a user. It's a string of format type#relation where #relation is optional. Treating it as a user is a hack. It should have a unique representation and converters to/from proto. Not sure that belongs in this package listusers either, but we can revisit that later. We're probably missing a pkg/types package where human readable helpers can convert to/from protos?

Lets not look too much into the argument name. We're just using an established convention to specify type and optional relation, why would we create a whole new system for this? It's only to facilitate our integration testing too.

This reverts commit 25c237f.
@willvedd willvedd merged commit 89736da into main May 29, 2024
15 of 17 checks passed
@willvedd willvedd deleted the list-users branch May 29, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants