@@ -18,6 +18,7 @@ import (
18
18
19
19
"cdr.dev/slog"
20
20
21
+ "github.com/coder/coder/v2/coderd/prebuilds"
21
22
"github.com/coder/coder/v2/coderd/rbac/policy"
22
23
"github.com/coder/coder/v2/coderd/rbac/rolestore"
23
24
@@ -358,6 +359,27 @@ var (
358
359
}),
359
360
Scope : rbac .ScopeAll ,
360
361
}.WithCachedASTValue ()
362
+
363
+ subjectPrebuildsOrchestrator = rbac.Subject {
364
+ FriendlyName : "Prebuilds Orchestrator" ,
365
+ ID : prebuilds .OwnerID .String (),
366
+ Roles : rbac .Roles ([]rbac.Role {
367
+ {
368
+ Identifier : rbac.RoleIdentifier {Name : "prebuilds-orchestrator" },
369
+ DisplayName : "Coder" ,
370
+ Site : rbac .Permissions (map [string ][]policy.Action {
371
+ // May use template, read template-related info, & insert template-related resources (preset prebuilds).
372
+ rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate , policy .ActionUse },
373
+ // May CRUD workspaces, and start/stop them.
374
+ rbac .ResourceWorkspace .Type : {
375
+ policy .ActionCreate , policy .ActionDelete , policy .ActionRead , policy .ActionUpdate ,
376
+ policy .ActionWorkspaceStart , policy .ActionWorkspaceStop ,
377
+ },
378
+ }),
379
+ },
380
+ }),
381
+ Scope : rbac .ScopeAll ,
382
+ }.WithCachedASTValue ()
361
383
)
362
384
363
385
// AsProvisionerd returns a context with an actor that has permissions required
@@ -412,6 +434,12 @@ func AsSystemReadProvisionerDaemons(ctx context.Context) context.Context {
412
434
return context .WithValue (ctx , authContextKey {}, subjectSystemReadProvisionerDaemons )
413
435
}
414
436
437
+ // AsPrebuildsOrchestrator returns a context with an actor that has permissions
438
+ // to read orchestrator workspace prebuilds.
439
+ func AsPrebuildsOrchestrator (ctx context.Context ) context.Context {
440
+ return context .WithValue (ctx , authContextKey {}, subjectPrebuildsOrchestrator )
441
+ }
442
+
415
443
var AsRemoveActor = rbac.Subject {
416
444
ID : "remove-actor" ,
417
445
}
0 commit comments