mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(coderd): require deployment-wide workspace read permissions for WatchAllWorkspaceBuilds endpoint (#26985)
This commit is contained in:
@@ -2249,6 +2249,20 @@ func (api *API) watchWorkspace(
|
||||
func (api *API) watchAllWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
// This endpoint streams build events for every workspace in the deployment
|
||||
// with no per-item filtering, so require deployment-wide read on workspaces.
|
||||
// Without this, any authenticated user could enumerate all workspace names
|
||||
// and observe build activity across organizations they do not belong to.
|
||||
if !api.Authorize(r, policy.ActionRead, rbac.ResourceWorkspace.All()) {
|
||||
httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{
|
||||
Message: "You are not authorized to watch all workspace builds.",
|
||||
Detail: "This requires permission to read all workspaces, which is granted by the " +
|
||||
"Owner or Template Admin role. Please contact an administrator about your " +
|
||||
"permissions if you feel this is an error.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Buffer enough updates to avoid blocking the pubsub callback while we're
|
||||
// accepting the WebSocket connection. Accepting the connection signals to
|
||||
// the client that the server is subscribed and ready to forward events.
|
||||
|
||||
Reference in New Issue
Block a user