- Notifications
You must be signed in to change notification settings - Fork1k
feat(coderd): add tasks rbac object#20234
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
base:main
Are you sure you want to change the base?
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.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Revert Tasks RBAC. | ||
-- No-op: enum values remain to avoid churn. Removing enum values requires | ||
-- doing a create/cast/drop cycle which is intentionally omitted here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Tasks RBAC. | ||
ALTER TYPE api_key_scope ADD VALUE IF NOT EXISTS 'task:create'; | ||
ALTER TYPE api_key_scope ADD VALUE IF NOT EXISTS 'task:read'; | ||
ALTER TYPE api_key_scope ADD VALUE IF NOT EXISTS 'task:update'; | ||
ALTER TYPE api_key_scope ADD VALUE IF NOT EXISTS 'task:delete'; | ||
ALTER TYPE api_key_scope ADD VALUE IF NOT EXISTS 'task:*'; |
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 |
---|---|---|
@@ -272,15 +272,17 @@ func ReloadBuiltinRoles(opts *RoleOptions) { | ||
// Workspace dormancy and workspace are omitted. | ||
// Workspace is specifically handled based on the opts.NoOwnerWorkspaceExec. | ||
// Owners cannot access other users' secrets. | ||
allPermsExcept(ResourceWorkspaceDormant, ResourcePrebuiltWorkspace, ResourceWorkspace,ResourceTask,ResourceUserSecret, ResourceUsageEvent), | ||
// This adds back in the Workspaceand Taskpermissions. | ||
Permissions(map[string][]policy.Action{ | ||
ResourceWorkspace.Type: ownerWorkspaceActions, | ||
ResourceWorkspaceDormant.Type: {policy.ActionRead, policy.ActionDelete, policy.ActionCreate, policy.ActionUpdate, policy.ActionWorkspaceStop, policy.ActionCreateAgent, policy.ActionDeleteAgent}, | ||
// PrebuiltWorkspaces are a subset of Workspaces. | ||
// Explicitly setting PrebuiltWorkspace permissions for clarity. | ||
// Note: even without PrebuiltWorkspace permissions, access is still granted via Workspace permissions. | ||
ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete}, | ||
// Tasks have similar permissions to workspaces. | ||
ResourceTask.Type: {policy.ActionRead, policy.ActionCreate, policy.ActionUpdate, policy.ActionDelete}, | ||
Comment on lines +275 to +285 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'm slightly confused by this, we're removing all the task permissions and then adding them all back again? Is this to protect against accidentally giving permissions to future additions to 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 was just following suite to what's done to workspaces as tasks have similar permissions. I'm happy to remove this if it's unnecessary. 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'm fine with it as-is 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. Workspaces actually omits some actions. Enumerating is always going to be more explicit, but if this is all the actions for a task, you can just leave it implied from | ||
})...), | ||
Org: map[string][]Permission{}, | ||
User: []Permission{}, | ||
@@ -296,10 +298,12 @@ func ReloadBuiltinRoles(opts *RoleOptions) { | ||
ResourceWorkspaceProxy.Type: {policy.ActionRead}, | ||
}), | ||
Org: map[string][]Permission{}, | ||
User: append(allPermsExcept(ResourceWorkspaceDormant, ResourcePrebuiltWorkspace,ResourceTask,ResourceUser, ResourceOrganizationMember), | ||
Permissions(map[string][]policy.Action{ | ||
// Reduced permission set on dormant workspaces. No build, ssh, or exec | ||
ResourceWorkspaceDormant.Type: {policy.ActionRead, policy.ActionDelete, policy.ActionCreate, policy.ActionUpdate, policy.ActionWorkspaceStop, policy.ActionCreateAgent, policy.ActionDeleteAgent}, | ||
// Users can perform all actions on their own tasks. | ||
ResourceTask.Type: {policy.ActionRead, policy.ActionCreate, policy.ActionUpdate, policy.ActionDelete}, | ||
// Users cannot do create/update/delete on themselves, but they | ||
// can read their own details. | ||
ResourceUser.Type: {policy.ActionRead, policy.ActionReadPersonal, policy.ActionUpdatePersonal}, | ||
@@ -421,13 +425,15 @@ func ReloadBuiltinRoles(opts *RoleOptions) { | ||
}), | ||
Org: map[string][]Permission{ | ||
// Org admins should not have workspace exec perms. | ||
organizationID.String(): append(allPermsExcept(ResourceWorkspace, ResourceWorkspaceDormant, ResourcePrebuiltWorkspace,ResourceTask,ResourceAssignRole, ResourceUserSecret), Permissions(map[string][]policy.Action{ | ||
ResourceWorkspaceDormant.Type: {policy.ActionRead, policy.ActionDelete, policy.ActionCreate, policy.ActionUpdate, policy.ActionWorkspaceStop, policy.ActionCreateAgent, policy.ActionDeleteAgent}, | ||
ResourceWorkspace.Type: slice.Omit(ResourceWorkspace.AvailableActions(), policy.ActionApplicationConnect, policy.ActionSSH), | ||
// PrebuiltWorkspaces are a subset of Workspaces. | ||
// Explicitly setting PrebuiltWorkspace permissions for clarity. | ||
// Note: even without PrebuiltWorkspace permissions, access is still granted via Workspace permissions. | ||
ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete}, | ||
// Org admins can manage all tasks in their organization. | ||
ResourceTask.Type: {policy.ActionRead, policy.ActionCreate, policy.ActionUpdate, policy.ActionDelete}, | ||
})...), | ||
}, | ||
User: []Permission{}, | ||
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.
Uh oh!
There was an error while loading.Please reload this page.