Skip to content

Commit 0e7f9fa

Browse files
committed
tabs to spaces
1 parent adae379 commit 0e7f9fa

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

coderd/authz/policy.rego

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ import future.keywords.every
1010
# bool_flip lets you assign a value to an inverted bool.
1111
# You cannot do 'x := !false', but you can do 'x := bool_flip(false)'
1212
bool_flip(b) = flipped {
13-
b
14-
flipped = false
13+
b
14+
flipped = false
1515
}
1616

1717
bool_flip(b) = flipped {
18-
not b
19-
flipped = true
18+
not b
19+
flipped = true
2020
}
2121

2222
# perms_grant returns a set of boolean values (true, false).
2323
# It will only return `bool_flip(perm.negate)` for permissions that affect a given
2424
# resource_type, resource_id, and action.
2525
# The empty set is returned if no relevant permissions are found.
2626
perms_grant(permissions) = grants {
27-
# If there are no permissions, this value is the empty set {}.
28-
grants := { x |
29-
# All permissions ...
30-
perm := permissions[_]
31-
# Such that the permission action, type, and resource_id matches
32-
perm.action in [input.action, "*"]
27+
# If there are no permissions, this value is the empty set {}.
28+
grants := { x |
29+
# All permissions ...
30+
perm := permissions[_]
31+
# Such that the permission action, type, and resource_id matches
32+
perm.action in [input.action, "*"]
3333
perm.resource_type in [input.object.type, "*"]
3434
perm.resource_id in [input.object.id, "*"]
3535
x := bool_flip(perm.negate)
@@ -40,23 +40,23 @@ perms_grant(permissions) = grants {
4040
# result is the default value.
4141
default site = {}
4242
site = grant {
43-
# Boolean set for all site wide permissions.
43+
# Boolean set for all site wide permissions.
4444
grant = { v | # Use set comprehension to remove dulpicate values
4545
# For each role, grab the site permission.
4646
# Find the grants on this permission list.
47-
v = perms_grant(input.subject.roles[_].site)[_]
47+
v = perms_grant(input.subject.roles[_].site)[_]
4848
}
4949
}
5050

5151
default user = {}
5252
user = grant {
53-
# Only apply user permissions if the user owns the resource
53+
# Only apply user permissions if the user owns the resource
5454
input.object.owner != ""
55-
input.object.owner == input.subject.id
55+
input.object.owner == input.subject.id
5656
grant = { v | # Use set comprehension to remove dulpicate values
5757
# For each role, grab the user permissions.
5858
# Find the grants on this permission list.
59-
v = perms_grant(input.subject.roles[_].user)[_]
59+
v = perms_grant(input.subject.roles[_].user)[_]
6060
}
6161
}
6262

@@ -67,19 +67,19 @@ user = grant {
6767
# org_member returns the set of permissions associated with a user if the user is a member of the
6868
# organization
6969
org_member = grant {
70-
input.object.org_owner != ""
70+
input.object.org_owner != ""
7171
grant = { v |
72-
v = perms_grant(input.subject.roles[_].org[input.object.org_owner])[_]
72+
v = perms_grant(input.subject.roles[_].org[input.object.org_owner])[_]
7373
}
7474
}
7575

7676
# If a user is not part of an organization, 'org_non_member' is set to true
7777
org_non_member {
78-
input.object.org_owner != ""
79-
# Identify if the user is in the org
78+
input.object.org_owner != ""
79+
# Identify if the user is in the org
8080
roles := input.subject.roles
8181
every role in roles {
82-
not role.org[input.object.org_owner]
82+
not role.org[input.object.org_owner]
8383
}
8484
}
8585

@@ -90,12 +90,12 @@ org_non_member {
9090
# It is important both rules cannot be true, as the `org` rules cannot produce multiple outputs.
9191
default org = []
9292
org = set {
93-
not org_non_member
94-
set = org_member
93+
not org_non_member
94+
set = org_member
9595
}
9696

9797
org = set {
98-
org_non_member
98+
org_non_member
9999
set = {false}
100100
}
101101

@@ -106,17 +106,17 @@ org = set {
106106

107107
# site allow
108108
allow {
109-
# No site wide deny
109+
# No site wide deny
110110
not false in site
111111
# And all permissions are positive
112112
site[_]
113113
}
114114

115115
# org allow
116116
allow {
117-
# No site or org deny
117+
# No site or org deny
118118
not false in site
119-
not false in org
119+
not false in org
120120
# And all permissions are positive
121121
org[_]
122122
}
@@ -125,7 +125,7 @@ allow {
125125
allow {
126126
# No site, org, or user deny
127127
not false in site
128-
not false in org
128+
not false in org
129129
not false in user
130130
# And all permissions are positive
131131
user[_]

0 commit comments

Comments
 (0)