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

Getting all users who have a specific permission / list of permissions on a specified resource #1706

Open
Godzilla5111 opened this issue Jun 12, 2023 · 2 comments

Comments

@Godzilla5111
Copy link

Is there some way to retrieve a list of users who can access a given resource/all users who are allowed to perform a specified action on a given resource?

i.e. input(resource, permission) -> output(users)

Can it be achieved using the query_rule() method??

Also, if it can be done, can it be extended to take in multiple permissions, and return the users who have all these permissions on the specified resource??

Say, with some structure like this-
get_users(permissions: List[str], resource: Resource) -> List[User]

An example would look like -
get_users(permissions = ["read", "write"], resource = g.session.query(Repo).filter_by(id=any_repo_id).one_or_none())

@hgbao
Copy link

hgbao commented Oct 6, 2023

Running into this issue too 🫠

@markgibaud-novata
Copy link

markgibaud-novata commented Jul 29, 2024

Example (thanks to Gabe) using the new nodejs sdk 2.0:

const user = typedVar("User");
    const anvilRepo = { type: "Repo", id: "anvil" };
    const usersAuthorizedToViewAnvilRepo = await oso
      .buildQuery(["allow", user, "view", anvilRepo])
      .evaluate(user);

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

No branches or pull requests

3 participants