@@ -8,10 +8,21 @@ import (
88"golang.org/x/xerrors"
99)
1010
11+ type WorkspaceAgentScopeParams struct {
12+ WorkspaceID uuid.UUID
13+ OwnerID uuid.UUID
14+ TemplateID uuid.UUID
15+ VersionID uuid.UUID
16+ }
17+
1118// WorkspaceAgentScope returns a scope that is the same as ScopeAll but can only
1219// affect resources in the allow list. Only a scope is returned as the roles
1320// should come from the workspace owner.
14- func WorkspaceAgentScope (workspaceID ,ownerID uuid.UUID )Scope {
21+ func WorkspaceAgentScope (params WorkspaceAgentScopeParams )Scope {
22+ if params .WorkspaceID == uuid .Nil || params .OwnerID == uuid .Nil || params .TemplateID == uuid .Nil || params .VersionID == uuid .Nil {
23+ panic ("all uuids must be non-nil, this is a developer error" )
24+ }
25+
1526allScope ,err := ScopeAll .Expand ()
1627if err != nil {
1728panic ("failed to expand scope all, this should never happen" )
@@ -23,10 +34,13 @@ func WorkspaceAgentScope(workspaceID, ownerID uuid.UUID) Scope {
2334// and evolving.
2435Role :allScope .Role ,
2536// This prevents the agent from being able to access any other resource.
37+ // Include the list of IDs of anything that is required for the
38+ // agent to function.
2639AllowIDList : []string {
27- workspaceID .String (),
28- ownerID .String (),
29- // TODO: Might want to include the template the workspace uses too?
40+ params .WorkspaceID .String (),
41+ params .TemplateID .String (),
42+ params .VersionID .String (),
43+ params .OwnerID .String (),
3044},
3145}
3246}