@@ -114,16 +114,16 @@ site_allow(roles) := num if {
114
114
# Adding a second org_members set might affect the partial evaluation.
115
115
# This is being left until org scopes are used.
116
116
org_members:= {orgID|
117
- input.subject.roles[_].org [orgID]
117
+ input.subject.roles[_].by_org_id [orgID]
118
118
}
119
119
120
120
# 'org' is the same as 'site' except we need to iterate over each organization
121
121
# that the actor is a member of.
122
122
default org:= 0
123
- org:= org_allow (input.subject.roles)
123
+ org:= org_allow (input.subject.roles, " org " )
124
124
125
125
default scope_org:= 0
126
- scope_org:= org_allow ([input.subject.scope])
126
+ scope_org:= org_allow ([input.subject.scope], " org " )
127
127
128
128
# org_allow_set is a helper function that iterates over all orgs that the actor
129
129
# is a member of. For each organization it sets the numerical allow value
@@ -135,12 +135,12 @@ scope_org := org_allow([input.subject.scope])
135
135
# The reason we calculate this for all orgs, and not just the input.object.org_owner
136
136
# is that sometimes the input.object.org_owner is unknown. In those cases
137
137
# we have a list of org_ids that can we use in a SQL 'WHERE' clause.
138
- org_allow_set (roles):= allow_set if {
138
+ org_allow_set (roles, key ):= allow_set if {
139
139
allow_set:= {id: num|
140
140
id:= org_members[_]
141
141
set:= {is_allowed|
142
142
# Iterate over all org permissions in all roles
143
- perm:= roles[_].org [id][_]
143
+ perm:= roles[_].by_org_id [id][key ][_]
144
144
perm.action in [input.action," *" ]
145
145
perm.resource_type in [input.object.type," *" ]
146
146
@@ -151,11 +151,11 @@ org_allow_set(roles) := allow_set if {
151
151
}
152
152
}
153
153
154
- org_allow (roles):= num if {
154
+ org_allow (roles, key ):= num if {
155
155
# If the object has "any_org" set to true, then use the other
156
156
# org_allow block.
157
157
not input.object.any_org
158
- allow:= org_allow_set (roles)
158
+ allow:= org_allow_set (roles, key )
159
159
160
160
# Return only the org value of the input's org.
161
161
# The reason why we do not do this up front, is that we need to make sure
@@ -171,9 +171,9 @@ org_allow(roles) := num if {
171
171
# This is useful for UI elements when we want to conclude, "Can the user create
172
172
# a new template in any organization?"
173
173
# It is easier than iterating over every organization the user is apart of.
174
- org_allow (roles):= num if {
174
+ org_allow (roles, key ):= num if {
175
175
input.object.any_org# if this is false, this code block is not used
176
- allow:= org_allow_set (roles)
176
+ allow:= org_allow_set (roles, key )
177
177
178
178
# allow is a map of {"<org_id>": <number>}. We only care about values
179
179
# that are 1, and ignore the rest.