Skip to content

Commit 64e0f8c

Browse files
committed
Add actual scope to workspace agent ctx
1 parent 8858fd3 commit 64e0f8c

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

coderd/authzquery/context.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,29 @@ func WithWorkspaceAgentTokenContext(ctx context.Context, workspaceID uuid.UUID,
4444
return context.WithValue(ctx, authContextKey{}, rbac.Subject{
4545
ID: actorID.String(),
4646
Roles: roles,
47-
// TODO: @emyrk This scope is INCORRECT. The correct scope is a readonly
48-
// scope for the specified workspaceID. Limit the permissions as much as
49-
// possible. This is a temporary scope until the scope allow_list
50-
// functionality exists.
51-
Scope: rbac.ScopeAll,
47+
Scope: rbac.Scope{
48+
Role: rbac.Role{
49+
Name: "workspace-agent-scope",
50+
DisplayName: "Workspace Agent Scope",
51+
// TODO: More permissions are needed for the agent to work.
52+
Site: []rbac.Permission{
53+
{
54+
ResourceType: rbac.ResourceWorkspace.Type,
55+
Action: rbac.ActionRead,
56+
},
57+
{
58+
ResourceType: rbac.ResourceWorkspace.Type,
59+
Action: rbac.ActionRead,
60+
},
61+
// TODO: Read the workspace owner user.
62+
},
63+
Org: map[string][]rbac.Permission{},
64+
User: []rbac.Permission{},
65+
},
66+
// TODO: We need to whitelist more resources such as the workspace
67+
// owner.
68+
AllowIDList: []string{workspaceID.String()},
69+
},
5270
Groups: groups,
5371
})
5472
}

0 commit comments

Comments
 (0)