@@ -169,7 +169,7 @@ var (
169
169
rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate },
170
170
// Unsure why provisionerd needs update and read personal
171
171
rbac .ResourceUser .Type : {policy .ActionRead , policy .ActionReadPersonal , policy .ActionUpdatePersonal },
172
- rbac .ResourceWorkspace .Type : {policy .ActionRead , policy .ActionUpdate , policy .ActionDelete , policy .ActionWorkspaceBuild },
172
+ rbac .ResourceWorkspace .Type : {policy .ActionRead , policy .ActionUpdate , policy .ActionDelete , policy .ActionWorkspaceStart , policy . ActionWorkspaceStop },
173
173
rbac .ResourceApiKey .Type : {policy .WildcardSymbol },
174
174
// When org scoped provisioner credentials are implemented,
175
175
// this can be reduced to read a specific org.
@@ -193,7 +193,7 @@ var (
193
193
Site : rbac .Permissions (map [string ][]policy.Action {
194
194
rbac .ResourceSystem .Type : {policy .WildcardSymbol },
195
195
rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate },
196
- rbac .ResourceWorkspace .Type : {policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceBuild },
196
+ rbac .ResourceWorkspace .Type : {policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceStart , policy . ActionWorkspaceStop },
197
197
rbac .ResourceUser .Type : {policy .ActionRead },
198
198
}),
199
199
Org : map [string ][]rbac.Permission {},
@@ -232,7 +232,7 @@ var (
232
232
DisplayName : "Coder" ,
233
233
Site : rbac .Permissions (map [string ][]policy.Action {
234
234
rbac .ResourceWildcard .Type : {policy .ActionRead },
235
- rbac .ResourceApiKey .Type : { policy . ActionCreate , policy . ActionUpdate , policy . ActionDelete } ,
235
+ rbac .ResourceApiKey .Type : rbac . ResourceApiKey . AvailableActions () ,
236
236
rbac .ResourceGroup .Type : {policy .ActionCreate , policy .ActionUpdate },
237
237
rbac .ResourceAssignRole .Type : rbac .ResourceAssignRole .AvailableActions (),
238
238
rbac .ResourceSystem .Type : {policy .WildcardSymbol },
@@ -241,7 +241,7 @@ var (
241
241
rbac .ResourceAssignOrgRole .Type : {policy .ActionRead , policy .ActionCreate , policy .ActionDelete },
242
242
rbac .ResourceProvisionerDaemon .Type : {policy .ActionCreate , policy .ActionUpdate },
243
243
rbac .ResourceUser .Type : rbac .ResourceUser .AvailableActions (),
244
- rbac .ResourceWorkspace .Type : {policy .ActionUpdate , policy .ActionDelete , policy .ActionWorkspaceBuild , policy .ActionSSH },
244
+ rbac .ResourceWorkspace .Type : {policy .ActionUpdate , policy .ActionDelete , policy .ActionWorkspaceStart , policy . ActionWorkspaceStop , policy .ActionSSH },
245
245
rbac .ResourceWorkspaceProxy .Type : {policy .ActionCreate , policy .ActionUpdate , policy .ActionDelete },
246
246
}),
247
247
Org : map [string ][]rbac.Permission {},
@@ -2531,9 +2531,11 @@ func (q *querier) InsertWorkspaceBuild(ctx context.Context, arg database.InsertW
2531
2531
return xerrors .Errorf ("get workspace by id: %w" , err )
2532
2532
}
2533
2533
2534
- var action policy.Action = policy .ActionWorkspaceBuild
2534
+ var action policy.Action = policy .ActionWorkspaceStart
2535
2535
if arg .Transition == database .WorkspaceTransitionDelete {
2536
2536
action = policy .ActionDelete
2537
+ } else if arg .Transition == database .WorkspaceTransitionStop {
2538
+ action = policy .ActionWorkspaceStop
2537
2539
}
2538
2540
2539
2541
if err = q .authorizeContext (ctx , action , w ); err != nil {
@@ -3280,7 +3282,7 @@ func (q *querier) UpsertAppSecurityKey(ctx context.Context, data string) error {
3280
3282
}
3281
3283
3282
3284
func (q * querier ) UpsertApplicationName (ctx context.Context , value string ) error {
3283
- if err := q .authorizeContext (ctx , policy .ActionCreate , rbac .ResourceDeploymentConfig ); err != nil {
3285
+ if err := q .authorizeContext (ctx , policy .ActionUpdate , rbac .ResourceDeploymentConfig ); err != nil {
3284
3286
return err
3285
3287
}
3286
3288
return q .db .UpsertApplicationName (ctx , value )
@@ -3294,7 +3296,7 @@ func (q *querier) UpsertDefaultProxy(ctx context.Context, arg database.UpsertDef
3294
3296
}
3295
3297
3296
3298
func (q * querier ) UpsertHealthSettings (ctx context.Context , value string ) error {
3297
- if err := q .authorizeContext (ctx , policy .ActionCreate , rbac .ResourceDeploymentConfig ); err != nil {
3299
+ if err := q .authorizeContext (ctx , policy .ActionUpdate , rbac .ResourceDeploymentConfig ); err != nil {
3298
3300
return err
3299
3301
}
3300
3302
return q .db .UpsertHealthSettings (ctx , value )
0 commit comments