Skip to content

feat(coder): Add PATCH /templateversions/:templateversion endpoint #6698

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 23, 2023
Prev Previous commit
Fix: RBAC
  • Loading branch information
mtojek committed Mar 22, 2023
commit c792dca29369882d1a2b7170c7edd3b5615d0e0e
7 changes: 2 additions & 5 deletions coderd/database/dbauthz/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,11 @@ func (q *querier) UpdateTemplateScheduleByID(ctx context.Context, arg database.U
}

func (q *querier) UpdateTemplateVersionByID(ctx context.Context, arg database.UpdateTemplateVersionByIDParams) (database.TemplateVersion, error) {
// Must do an authorized fetch to prevent leaking template ids this way.
tpl, err := q.GetTemplateByID(ctx, arg.TemplateID.UUID)
template, err := q.db.GetTemplateByID(ctx, arg.TemplateID.UUID)
if err != nil {
return database.TemplateVersion{}, err
}
// Check the create permission on the template.
err = q.authorizeContext(ctx, rbac.ActionUpdate, tpl)
if err != nil {
if err := q.authorizeContext(ctx, rbac.ActionUpdate, template); err != nil {
return database.TemplateVersion{}, err
}
return q.db.UpdateTemplateVersionByID(ctx, arg)
Expand Down