mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
Merge branch 'main' of github.com:/coder/coder into dk/prebuilds
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
This commit is contained in:
@ -831,6 +831,15 @@ func (b *Builder) authorize(authFunc func(action policy.Action, object rbac.Obje
|
||||
return BuildError{http.StatusBadRequest, msg, xerrors.New(msg)}
|
||||
}
|
||||
if !authFunc(action, b.workspace) {
|
||||
if authFunc(policy.ActionRead, b.workspace) {
|
||||
// If the user can read the workspace, but not delete/create/update. Show
|
||||
// a more helpful error. They are allowed to know the workspace exists.
|
||||
return BuildError{
|
||||
Status: http.StatusForbidden,
|
||||
Message: fmt.Sprintf("You do not have permission to %s this workspace.", action),
|
||||
Wrapped: xerrors.New(httpapi.ResourceForbiddenResponse.Detail),
|
||||
}
|
||||
}
|
||||
// We use the same wording as the httpapi to avoid leaking the existence of the workspace
|
||||
return BuildError{http.StatusNotFound, httpapi.ResourceNotFoundResponse.Message, xerrors.New(httpapi.ResourceNotFoundResponse.Message)}
|
||||
}
|
||||
|
Reference in New Issue
Block a user