@@ -170,10 +170,10 @@ var (
170
170
Identifier : rbac.RoleIdentifier {Name : "provisionerd" },
171
171
DisplayName : "Provisioner Daemon" ,
172
172
Site : rbac .Permissions (map [string ][]policy.Action {
173
- // TODO: Add ProvisionerJob resource type.
174
- rbac .ResourceFile .Type : {policy .ActionRead },
175
- rbac .ResourceSystem .Type : {policy .WildcardSymbol },
176
- rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate },
173
+ rbac . ResourceProvisionerJobs . Type : { policy . ActionRead , policy . ActionUpdate },
174
+ rbac .ResourceFile .Type : {policy .ActionRead },
175
+ rbac .ResourceSystem .Type : {policy .WildcardSymbol },
176
+ rbac .ResourceTemplate .Type : {policy .ActionRead , policy .ActionUpdate },
177
177
// Unsure why provisionerd needs update and read personal
178
178
rbac .ResourceUser .Type : {policy .ActionRead , policy .ActionReadPersonal , policy .ActionUpdatePersonal },
179
179
rbac .ResourceWorkspaceDormant .Type : {policy .ActionDelete , policy .ActionRead , policy .ActionUpdate , policy .ActionWorkspaceStop },
@@ -1093,11 +1093,10 @@ func (q *querier) AcquireNotificationMessages(ctx context.Context, arg database.
1093
1093
return q .db .AcquireNotificationMessages (ctx , arg )
1094
1094
}
1095
1095
1096
- // TODO: We need to create a ProvisionerJob resource type
1097
1096
func (q * querier ) AcquireProvisionerJob (ctx context.Context , arg database.AcquireProvisionerJobParams ) (database.ProvisionerJob , error ) {
1098
- // if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceSystem ); err != nil {
1099
- // return database.ProvisionerJob{}, err
1100
- // }
1097
+ if err := q .authorizeContext (ctx , policy .ActionUpdate , rbac .ResourceProvisionerJobs ); err != nil {
1098
+ return database.ProvisionerJob {}, err
1099
+ }
1101
1100
return q .db .AcquireProvisionerJob (ctx , arg )
1102
1101
}
1103
1102
@@ -2322,28 +2321,28 @@ func (q *querier) GetProvisionerJobTimingsByJobID(ctx context.Context, jobID uui
2322
2321
return q .db .GetProvisionerJobTimingsByJobID (ctx , jobID )
2323
2322
}
2324
2323
2325
- // TODO: We have a ProvisionerJobs resource, but it hasn't been checked for this use-case.
2326
2324
func (q * querier ) GetProvisionerJobsByIDs (ctx context.Context , ids []uuid.UUID ) ([]database.ProvisionerJob , error ) {
2327
- // if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem ); err != nil {
2328
- // return nil, err
2329
- // }
2325
+ if err := q .authorizeContext (ctx , policy .ActionRead , rbac .ResourceProvisionerJobs ); err != nil {
2326
+ return nil , err
2327
+ }
2330
2328
return q .db .GetProvisionerJobsByIDs (ctx , ids )
2331
2329
}
2332
2330
2333
- // TODO: We have a ProvisionerJobs resource, but it hasn't been checked for this use-case.
2334
2331
func (q * querier ) GetProvisionerJobsByIDsWithQueuePosition (ctx context.Context , ids []uuid.UUID ) ([]database.GetProvisionerJobsByIDsWithQueuePositionRow , error ) {
2332
+ if err := q .authorizeContext (ctx , policy .ActionRead , rbac .ResourceProvisionerJobs ); err != nil {
2333
+ return nil , err
2334
+ }
2335
2335
return q .db .GetProvisionerJobsByIDsWithQueuePosition (ctx , ids )
2336
2336
}
2337
2337
2338
2338
func (q * querier ) GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner (ctx context.Context , arg database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerParams ) ([]database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerRow , error ) {
2339
2339
return fetchWithPostFilter (q .auth , policy .ActionRead , q .db .GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner )(ctx , arg )
2340
2340
}
2341
2341
2342
- // TODO: We have a ProvisionerJobs resource, but it hasn't been checked for this use-case.
2343
2342
func (q * querier ) GetProvisionerJobsCreatedAfter (ctx context.Context , createdAt time.Time ) ([]database.ProvisionerJob , error ) {
2344
- // if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem ); err != nil {
2345
- // return nil, err
2346
- // }
2343
+ if err := q .authorizeContext (ctx , policy .ActionRead , rbac .ResourceProvisionerJobs ); err != nil {
2344
+ return nil , err
2345
+ }
2347
2346
return q .db .GetProvisionerJobsCreatedAfter (ctx , createdAt )
2348
2347
}
2349
2348
@@ -3531,27 +3530,24 @@ func (q *querier) InsertPresetParameters(ctx context.Context, arg database.Inser
3531
3530
return q .db .InsertPresetParameters (ctx , arg )
3532
3531
}
3533
3532
3534
- // TODO: We need to create a ProvisionerJob resource type
3535
3533
func (q * querier ) InsertProvisionerJob (ctx context.Context , arg database.InsertProvisionerJobParams ) (database.ProvisionerJob , error ) {
3536
- // if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceSystem ); err != nil {
3537
- // return database.ProvisionerJob{}, err
3538
- // }
3534
+ if err := q .authorizeContext (ctx , policy .ActionCreate , rbac .ResourceProvisionerJobs ); err != nil {
3535
+ return database.ProvisionerJob {}, err
3536
+ }
3539
3537
return q .db .InsertProvisionerJob (ctx , arg )
3540
3538
}
3541
3539
3542
- // TODO: We need to create a ProvisionerJob resource type
3543
3540
func (q * querier ) InsertProvisionerJobLogs (ctx context.Context , arg database.InsertProvisionerJobLogsParams ) ([]database.ProvisionerJobLog , error ) {
3544
- // if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceSystem ); err != nil {
3545
- // return nil, err
3546
- // }
3541
+ if err := q .authorizeContext (ctx , policy .ActionCreate , rbac .ResourceProvisionerJobs ); err != nil {
3542
+ return nil , err
3543
+ }
3547
3544
return q .db .InsertProvisionerJobLogs (ctx , arg )
3548
3545
}
3549
3546
3550
- // TODO: We need to create a ProvisionerJob resource type
3551
3547
func (q * querier ) InsertProvisionerJobTimings (ctx context.Context , arg database.InsertProvisionerJobTimingsParams ) ([]database.ProvisionerJobTiming , error ) {
3552
- // if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceSystem ); err != nil {
3553
- // return nil, err
3554
- // }
3548
+ if err := q .authorizeContext (ctx , policy .ActionCreate , rbac .ResourceProvisionerJobs ); err != nil {
3549
+ return nil , err
3550
+ }
3555
3551
return q .db .InsertProvisionerJobTimings (ctx , arg )
3556
3552
}
3557
3553
@@ -4174,11 +4170,10 @@ func (q *querier) UpdateProvisionerDaemonLastSeenAt(ctx context.Context, arg dat
4174
4170
return q .db .UpdateProvisionerDaemonLastSeenAt (ctx , arg )
4175
4171
}
4176
4172
4177
- // TODO: We need to create a ProvisionerJob resource type
4178
4173
func (q * querier ) UpdateProvisionerJobByID (ctx context.Context , arg database.UpdateProvisionerJobByIDParams ) error {
4179
- // if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceSystem ); err != nil {
4180
- // return err
4181
- // }
4174
+ if err := q .authorizeContext (ctx , policy .ActionUpdate , rbac .ResourceProvisionerJobs ); err != nil {
4175
+ return err
4176
+ }
4182
4177
return q .db .UpdateProvisionerJobByID (ctx , arg )
4183
4178
}
4184
4179
0 commit comments