- Notifications
You must be signed in to change notification settings - Fork928
chore: introduceResourceWorkspaceAgent
RBAC resource#17824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -188,6 +188,8 @@ var ( | ||
// Provisionerd creates workspaces resources monitor | ||
rbac.ResourceWorkspaceAgentResourceMonitor.Type: {policy.ActionCreate}, | ||
rbac.ResourceWorkspaceAgentDevcontainers.Type: {policy.ActionCreate}, | ||
// Provisionerd creates workspace agents | ||
rbac.ResourceWorkspaceAgent.Type: {policy.ActionCreate}, | ||
}), | ||
Org: map[string][]rbac.Permission{}, | ||
User: []rbac.Permission{}, | ||
@@ -339,6 +341,7 @@ var ( | ||
rbac.ResourceUser.Type: rbac.ResourceUser.AvailableActions(), | ||
rbac.ResourceWorkspaceDormant.Type: {policy.ActionUpdate, policy.ActionDelete, policy.ActionWorkspaceStop}, | ||
rbac.ResourceWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete, policy.ActionWorkspaceStart, policy.ActionWorkspaceStop, policy.ActionSSH}, | ||
rbac.ResourceWorkspaceAgent.Type: {policy.ActionCreate, policy.ActionDelete, policy.ActionRead}, | ||
rbac.ResourceWorkspaceProxy.Type: {policy.ActionCreate, policy.ActionUpdate, policy.ActionDelete}, | ||
rbac.ResourceDeploymentConfig.Type: {policy.ActionCreate, policy.ActionUpdate, policy.ActionDelete}, | ||
rbac.ResourceNotificationMessage.Type: {policy.ActionCreate, policy.ActionRead, policy.ActionUpdate, policy.ActionDelete}, | ||
@@ -3014,14 +3017,14 @@ func (q *querier) GetWorkspaceAgentUsageStatsAndLabels(ctx context.Context, crea | ||
// GetWorkspaceAgentsByResourceIDs | ||
// The workspace/job is already fetched. | ||
func (q *querier) GetWorkspaceAgentsByResourceIDs(ctx context.Context, ids []uuid.UUID) ([]database.WorkspaceAgent, error) { | ||
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceWorkspaceAgent); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think this needs to be scoped by who ultimately "owns" the workspace agent (which is generally the owner of the associated workspace). Can a member read an owner's workspace agent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. You're absolutely right. As is, the change is status quo over the previous implementation but ultimately it would make more sense to make itbetter. Thanks 👍 | ||
return nil, err | ||
} | ||
return q.db.GetWorkspaceAgentsByResourceIDs(ctx, ids) | ||
} | ||
func (q *querier) GetWorkspaceAgentsCreatedAfter(ctx context.Context, createdAt time.Time) ([]database.WorkspaceAgent, error) { | ||
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceWorkspaceAgent); err != nil { | ||
return nil, err | ||
} | ||
return q.db.GetWorkspaceAgentsCreatedAfter(ctx, createdAt) | ||
@@ -3691,7 +3694,7 @@ func (q *querier) InsertWorkspace(ctx context.Context, arg database.InsertWorksp | ||
} | ||
func (q *querier) InsertWorkspaceAgent(ctx context.Context, arg database.InsertWorkspaceAgentParams) (database.WorkspaceAgent, error) { | ||
if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceWorkspaceAgent); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can a member insert a workspace agent belonging to another user? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This would possibly allow that, yes. I'll have a chat with@Emyrk to ensure that doesn't happen. | ||
return database.WorkspaceAgent{}, err | ||
} | ||
return q.db.InsertWorkspaceAgent(ctx, arg) | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -335,4 +335,11 @@ var RBACPermissions = map[string]PermissionDefinition{ | ||
ActionCreate: actDef("create workspace agent devcontainers"), | ||
}, | ||
}, | ||
"workspace_agent": { | ||
Actions: map[Action]ActionDefinition{ | ||
ActionRead: actDef("read workspace agent"), | ||
ActionDelete: actDef("delete workspace agent"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't think we actually ever delete workspace agents, so this istechnically not required (yet) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Correct, we don'tyet, although we will be in the upcoming devcontainer agents work. I'm happy to remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That's a great reason to leave it in :) | ||
ActionCreate: actDef("create workspace agent"), | ||
}, | ||
}, | ||
} |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.