Skip to content

Commit 4528e81

Browse files
committed
fix: adjust build state permission to require template update
1 parent d8abe37 commit 4528e81

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

coderd/workspacebuilds.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,18 @@ func (api *API) workspaceBuildState(rw http.ResponseWriter, r *http.Request) {
892892
})
893893
return
894894
}
895+
template, err := api.Database.GetTemplateByID(ctx, workspace.TemplateID)
896+
if err != nil {
897+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
898+
Message: "Failed to get template",
899+
Detail: err.Error(),
900+
})
901+
return
902+
}
895903

896-
if !api.Authorize(r, rbac.ActionRead, workspace) {
904+
// You must have update permissions on the template to get the state.
905+
// This matches a push!
906+
if !api.Authorize(r, rbac.ActionUpdate, template.RBACObject()) {
897907
httpapi.ResourceNotFound(rw)
898908
return
899909
}

0 commit comments

Comments
 (0)