brentpi_35990
12/11/2023, 8:05 AMdefinition user {
relation current:user
relation org:organization
permission is_admin = org->admin & current // ie: to check that the user object is both in 'current' (will only be one entry per user) and org->admin (multiple users)
}
definition organization {
relation admin: user
relation some_role: user
}
in order to check that a user is 'admin' through checking the 'user' object alone without caveats; is the only approach to create the following relations:
user:1#org@organization:1
user:1#current@user:1
organization:1#admin@user:1vroldanbet
12/11/2023, 10:00 AMuser
as a resource to authorize access to for.
What's the actual requirement you want to implement? Is it to show in a UI which roles does the user have? The way this is typically solved is by running ReadRelationships
over the relation that assigns the admin role to a user. For example, this could be organization#admin
. You can use the ReadRelationship
API to do a exact match over the user you are looking for, so that the API returns either one or zero relationships.brentpi_35990
12/11/2023, 12:01 PMbrentpi_35990
12/11/2023, 12:04 PMvroldanbet
12/11/2023, 2:22 PMvroldanbet
12/11/2023, 2:25 PMdefinition organization {
relation member: user
relation repos: repository
relation advanced_security: user:*
permission can_enable_dependabot: advanced_security & member
}
definition repository {
relation owner: organization | user
permission can_enable_dependabot: owner->can_advanced_security
}
vroldanbet
12/11/2023, 2:27 PMvroldanbet
12/11/2023, 2:28 PMbrentpi_35990
12/11/2023, 9:37 PM