Skip to content

chore: reorder prebuilt workspace authorization logic #18506

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 6 commits into from
Jun 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: simplify workspace type assertion
  • Loading branch information
ssncferreira committed Jun 24, 2025
commit 2c387ce20ef90be5fda727a368ac1dbea628491c
7 changes: 5 additions & 2 deletions coderd/workspacebuilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,11 @@ func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
return true
}
// Special handling for prebuilt workspace deletion
if object.RBACObject().Type == rbac.ResourceWorkspace.Type && action == policy.ActionDelete {
if workspaceObj, ok := object.(database.Workspace); ok && workspaceObj.IsPrebuild() {
if action == policy.ActionDelete {
if workspaceObj, ok := object.(interface {
IsPrebuild() bool
AsPrebuild() rbac.Object
}); ok && workspaceObj.IsPrebuild() {
return api.Authorize(r, action, workspaceObj.AsPrebuild())
}
}
Expand Down
Loading