@@ -158,49 +158,34 @@ func ActorFromContext(ctx context.Context) (rbac.Subject, bool) {
158
158
}
159
159
160
160
var (
161
- subjectProvisionerd = func (orgID uuid.UUID ) rbac.Subject {
162
- sitePermissions := map [string ][]policy.Action {
163
- // TODO: Add ProvisionerJob resource type.
164
- rbac .ResourceFile .Type : {policy .ActionRead },
165
- rbac .ResourceSystem .Type : {policy .WildcardSymbol },
166
- rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate },
167
- // Unsure why provisionerd needs update and read personal
168
- rbac .ResourceUser .Type : {policy .ActionRead , policy .ActionReadPersonal , policy .ActionUpdatePersonal },
169
- rbac .ResourceWorkspaceDormant .Type : {policy .ActionDelete , policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceStop },
170
- rbac .ResourceWorkspace .Type : {policy .ActionDelete , policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceStart , policy .ActionWorkspaceStop },
171
- rbac .ResourceApiKey .Type : {policy .WildcardSymbol },
172
- // When org scoped provisioner credentials are implemented,
173
- // this can be reduced to read a specific org.
174
- rbac .ResourceOrganization .Type : {policy .ActionRead },
175
- rbac .ResourceGroup .Type : {policy .ActionRead },
176
- }
177
- orgPermissions := map [string ][]rbac.Permission {}
178
-
179
- if orgID != uuid .Nil {
180
- // replace site wide org permissions with org scoped permissions
181
- delete (sitePermissions , rbac .ResourceOrganization .Type )
182
- orgPermissions = map [string ][]rbac.Permission {
183
- orgID .String (): rbac .Permissions (map [string ][]policy.Action {
161
+ subjectProvisionerd = rbac.Subject {
162
+ FriendlyName : "Provisioner Daemon" ,
163
+ ID : uuid .Nil .String (),
164
+ Roles : rbac .Roles ([]rbac.Role {
165
+ {
166
+ Identifier : rbac.RoleIdentifier {Name : "provisionerd" },
167
+ DisplayName : "Provisioner Daemon" ,
168
+ Site : rbac .Permissions (map [string ][]policy.Action {
169
+ // TODO: Add ProvisionerJob resource type.
170
+ rbac .ResourceFile .Type : {policy .ActionRead },
171
+ rbac .ResourceSystem .Type : {policy .WildcardSymbol },
172
+ rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate },
173
+ // Unsure why provisionerd needs update and read personal
174
+ rbac .ResourceUser .Type : {policy .ActionRead , policy .ActionReadPersonal , policy .ActionUpdatePersonal },
175
+ rbac .ResourceWorkspaceDormant .Type : {policy .ActionDelete , policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceStop },
176
+ rbac .ResourceWorkspace .Type : {policy .ActionDelete , policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceStart , policy .ActionWorkspaceStop },
177
+ rbac .ResourceApiKey .Type : {policy .WildcardSymbol },
178
+ // When org scoped provisioner credentials are implemented,
179
+ // this can be reduced to read a specific org.
184
180
rbac .ResourceOrganization .Type : {policy .ActionRead },
181
+ rbac .ResourceGroup .Type : {policy .ActionRead },
185
182
}),
186
- }
187
- }
188
-
189
- return rbac.Subject {
190
- FriendlyName : "Provisioner Daemon" ,
191
- ID : uuid .Nil .String (),
192
- Roles : rbac .Roles ([]rbac.Role {
193
- {
194
- Identifier : rbac.RoleIdentifier {Name : "provisionerd" },
195
- DisplayName : "Provisioner Daemon" ,
196
- Site : rbac .Permissions (sitePermissions ),
197
- Org : orgPermissions ,
198
- User : []rbac.Permission {},
199
- },
200
- }),
201
- Scope : rbac .ScopeAll ,
202
- }.WithCachedASTValue ()
203
- }
183
+ Org : map [string ][]rbac.Permission {},
184
+ User : []rbac.Permission {},
185
+ },
186
+ }),
187
+ Scope : rbac .ScopeAll ,
188
+ }.WithCachedASTValue ()
204
189
205
190
subjectAutostart = rbac.Subject {
206
191
FriendlyName : "Autostart" ,
@@ -277,13 +262,7 @@ var (
277
262
// AsProvisionerd returns a context with an actor that has permissions required
278
263
// for provisionerd to function.
279
264
func AsProvisionerd (ctx context.Context ) context.Context {
280
- return context .WithValue (ctx , authContextKey {}, subjectProvisionerd (uuid .Nil ))
281
- }
282
-
283
- // AsProvisionerd returns a context with an actor that has permissions required
284
- // for an org scoped provisionerd to function.
285
- func AsOrganizationProvisionerd (ctx context.Context , orgID uuid.UUID ) context.Context {
286
- return context .WithValue (ctx , authContextKey {}, subjectProvisionerd (orgID ))
265
+ return context .WithValue (ctx , authContextKey {}, subjectProvisionerd )
287
266
}
288
267
289
268
// AsAutostart returns a context with an actor that has permissions required
0 commit comments