Skip to content

Commit ca68db2

Browse files
committed
Remove duplicate workspace agent scope
1 parent bf653b6 commit ca68db2

File tree

2 files changed

+4
-41
lines changed

2 files changed

+4
-41
lines changed

coderd/authzquery/context.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,47 +30,6 @@ func WithAuthorizeContext(ctx context.Context, actor rbac.Subject) context.Conte
3030
return context.WithValue(ctx, authContextKey{}, actor)
3131
}
3232

33-
// WithWorkspaceAgentTokenContext returns a context with a workspace agent token
34-
// authorization subject. A workspace agent authorization subject is the
35-
// workspace owner's authorization subject + a workspace agent scope.
36-
//
37-
// TODO: The arguments and usage of this function are not finalized. It might
38-
// be a bit awkward to use at present. The arguments are required to build the
39-
// required authorization context. The arguments should be the owner of the
40-
// workspace authorization roles.
41-
func WithWorkspaceAgentTokenContext(ctx context.Context, workspaceID uuid.UUID, actorID uuid.UUID, roles rbac.ExpandableRoles, groups []string) context.Context {
42-
// TODO: This workspace ID should be applied in the scope.
43-
var _ = workspaceID
44-
return context.WithValue(ctx, authContextKey{}, rbac.Subject{
45-
ID: actorID.String(),
46-
Roles: roles,
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-
},
70-
Groups: groups,
71-
})
72-
}
73-
7433
// ActorFromContext returns the authorization subject from the context.
7534
// All authentication flows should set the authorization subject in the context.
7635
// If no actor is present, the function returns false.

coderd/rbac/scopes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func (s Scope) Name() string {
4343
return s.Role.Name
4444
}
4545

46+
// WorkspaceAgentScope returns a scope that is the same as ScopeAll but can only
47+
// affect resources in the allow list. Only a scope is returned as the roles
48+
// should come from the workspace owner.
4649
func WorkspaceAgentScope(workspaceID, ownerID uuid.UUID) Scope {
4750
allScope, err := ScopeAll.Expand()
4851
if err != nil {
@@ -58,6 +61,7 @@ func WorkspaceAgentScope(workspaceID, ownerID uuid.UUID) Scope {
5861
AllowIDList: []string{
5962
workspaceID.String(),
6063
ownerID.String(),
64+
// TODO: Might want to include the template the workspace uses too?
6165
},
6266
}
6367
}

0 commit comments

Comments
 (0)