- Notifications
You must be signed in to change notification settings - Fork1k
feat: add an organization member permission level#19953
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:lilac/by-org-id
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
77432a2
3f0a5bf
b748e6a
74a6c99
c24d0dc
8135c68
945b0cb
4344ed2
ff6552e
70651c6
dcf52f8
6c64621
52f1d1c
b8446de
a648977
fd71845
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -232,6 +232,9 @@ scope_user := user_allow([input.subject.scope]) | ||
user_allow(roles) := num if { | ||
input.object.owner != "" | ||
# if there is an org, use org_member permissions instead | ||
input.object.org_owner == "" | ||
not input.object.any_org | ||
Emyrk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
input.subject.id = input.object.owner | ||
allow := {is_allowed | | ||
@@ -246,6 +249,28 @@ user_allow(roles) := num if { | ||
num := number(allow) | ||
} | ||
# ------------------- | ||
# Organization Member Owner Rules | ||
# ------------------- | ||
# 'org_member' applies if the object is owned by both the user and an organization. | ||
# It replaces the `user` permissions in this case. | ||
default org_member := 0 | ||
org_member := num if { | ||
# Object must be jointly owned by the user | ||
input.object.owner != "" | ||
input.subject.id = input.object.owner | ||
num := org_allow(input.subject.roles, "member") | ||
} | ||
default scope_org_member := 0 | ||
scope_org_member := num if { | ||
# Object must be jointly owned by the user | ||
input.object.owner != "" | ||
input.subject.id = input.object.owner | ||
num := org_allow([input.subject.scope], "member") | ||
} | ||
# Scope allow_list is a list of resource (Type, ID) tuples explicitly allowed by the scope. | ||
# If the list contains `(*,*)`, then all resources are allowed. | ||
scope_allow_list if { | ||
@@ -285,16 +310,16 @@ scope_allow_list if { | ||
# Role-Specific Rules | ||
# ------------------- | ||
role_allow if { # site level authed | ||
site = 1 | ||
} | ||
role_allow if { # org level authed | ||
not site = -1 | ||
org = 1 | ||
} | ||
role_allow if { # user level authed | ||
not site = -1 | ||
not org = -1 | ||
@@ -304,22 +329,30 @@ role_allow if { | ||
user = 1 | ||
} | ||
role_allow if { # org member auth | ||
not site = -1 | ||
not org = -1 | ||
# Organization member owner permissions require both ownership and org membership | ||
org_member = 1 | ||
} | ||
# ------------------- | ||
# Scope-Specific Rules | ||
# ------------------- | ||
scope_allow if { # scope site level authed | ||
scope_allow_list | ||
scope_site = 1 | ||
} | ||
scope_allow if { # scope org level authed | ||
scope_allow_list | ||
not scope_site = -1 | ||
scope_org = 1 | ||
} | ||
scope_allow if { # scope user level authed | ||
scope_allow_list | ||
not scope_site = -1 | ||
not scope_org = -1 | ||
@@ -330,6 +363,15 @@ scope_allow if { | ||
scope_user = 1 | ||
} | ||
scope_allow if { # scope org member auth | ||
scope_allow_list | ||
not scope_site = -1 | ||
not scope_org = -1 | ||
# Organization member owner permissions require both ownership and org membership | ||
scope_org_member = 1 | ||
} | ||
# ------------------- | ||
# ACL-Specific Rules | ||
# Access Control List | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.