Skip to content

Commit bde8870

Browse files
committed
Remove excess diffs
1 parent a9ad485 commit bde8870

File tree

6 files changed

+20
-37
lines changed

6 files changed

+20
-37
lines changed

coderd/authorize.go

+18-24
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type HTTPAuthorizer struct {
5151
// return
5252
// }
5353
func (api *API) Authorize(r *http.Request, action rbac.Action, object rbac.Objecter) bool {
54-
return api.HTTPAuth.Authorize(r, action, object, true)
54+
return api.HTTPAuth.Authorize(r, action, object)
5555
}
5656

5757
// Authorize will return false if the user is not authorized to do the action.
@@ -63,33 +63,27 @@ func (api *API) Authorize(r *http.Request, action rbac.Action, object rbac.Objec
6363
// httpapi.Forbidden(rw)
6464
// return
6565
// }
66-
func (h *HTTPAuthorizer) Authorize(r *http.Request, action rbac.Action, object rbac.Objecter, logUnauthorized bool) bool {
66+
func (h *HTTPAuthorizer) Authorize(r *http.Request, action rbac.Action, object rbac.Objecter) bool {
6767
roles := httpmw.UserAuthorization(r)
6868
err := h.Authorizer.Authorize(r.Context(), roles.Actor, action, object.RBACObject())
6969
if err != nil {
70-
// Sometimes we do not want to log the unauthorized errors.
71-
// Example: If an endpoint expects the normal case to return unauthorized
72-
// to check a user is not an admin, we do not want to log that since it is
73-
// the expected path.
74-
if logUnauthorized {
75-
// Log the errors for debugging
76-
internalError := new(rbac.UnauthorizedError)
77-
logger := h.Logger
78-
if xerrors.As(err, internalError) {
79-
logger = h.Logger.With(slog.F("internal", internalError.Internal()))
80-
}
81-
// Log information for debugging. This will be very helpful
82-
// in the early days
83-
logger.Warn(r.Context(), "unauthorized",
84-
slog.F("roles", roles.Actor.SafeRoleNames()),
85-
slog.F("actor_id", roles.Actor.ID),
86-
slog.F("actor_name", roles.ActorName),
87-
slog.F("scope", roles.Actor.SafeScopeName()),
88-
slog.F("route", r.URL.Path),
89-
slog.F("action", action),
90-
slog.F("object", object),
91-
)
70+
// Log the errors for debugging
71+
internalError := new(rbac.UnauthorizedError)
72+
logger := h.Logger
73+
if xerrors.As(err, internalError) {
74+
logger = h.Logger.With(slog.F("internal", internalError.Internal()))
9275
}
76+
// Log information for debugging. This will be very helpful
77+
// in the early days
78+
logger.Warn(r.Context(), "unauthorized",
79+
slog.F("roles", roles.Actor.SafeRoleNames()),
80+
slog.F("actor_id", roles.Actor.ID),
81+
slog.F("actor_name", roles.ActorName),
82+
slog.F("scope", roles.Actor.SafeScopeName()),
83+
slog.F("route", r.URL.Path),
84+
slog.F("action", action),
85+
slog.F("object", object),
86+
)
9387

9488
return false
9589
}

coderd/rbac/object.go

-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ var (
3636
Type: "workspace_proxy",
3737
}
3838

39-
// ResourceWorkspaceProxyMetaData is a special resource that is used to
40-
// allow reading metadata for a given workspace proxy. This metadata should
41-
// not be revealed to all users, only administrators of the workspace proxy.
42-
ResourceWorkspaceProxyMetaData = Object{
43-
Type: "workspace_proxy_data",
44-
}
45-
4639
// ResourceWorkspaceExecution CRUD. Org + User owner
4740
// create = workspace remote execution
4841
// read = ?

coderd/rbac/object_gen.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/rbac/roles.go

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
151151
ResourceRoleAssignment.Type: {ActionRead},
152152
// All users can see the provisioner daemons.
153153
ResourceProvisionerDaemon.Type: {ActionRead},
154-
ResourceWorkspaceProxy.Type: {ActionRead},
155154
}),
156155
Org: map[string][]Permission{},
157156
User: allPermsExcept(),

enterprise/coderd/coderd.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func New(ctx context.Context, options *Options) (*API, error) {
9393
r.Use(apiKeyMiddleware)
9494
r.Post("/", api.reconnectingPTYSignedToken)
9595
})
96-
// These routes are for administering and managing workspace proxies.
9796
r.Route("/workspaceproxies", func(r chi.Router) {
9897
r.Use(
9998
api.moonsEnabledMW,
@@ -513,5 +512,5 @@ func (api *API) runEntitlementsLoop(ctx context.Context) {
513512
}
514513

515514
func (api *API) Authorize(r *http.Request, action rbac.Action, object rbac.Objecter) bool {
516-
return api.AGPL.HTTPAuth.Authorize(r, action, object, true)
515+
return api.AGPL.HTTPAuth.Authorize(r, action, object)
517516
}

enterprise/coderd/workspaceproxy.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (api *API) postWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
187187

188188
aReq.New = proxy
189189
httpapi.Write(ctx, rw, http.StatusCreated, codersdk.CreateWorkspaceProxyResponse{
190-
Proxy: api.convertProxy(r, proxy, proxyhealth.ProxyStatus{
190+
Proxy: convertProxy(proxy, proxyhealth.ProxyStatus{
191191
Proxy: proxy,
192192
CheckedAt: time.Now(),
193193
Status: proxyhealth.Unregistered,
@@ -459,7 +459,6 @@ func convertProxy(p database.WorkspaceProxy, status proxyhealth.ProxyStatus) cod
459459
return codersdk.WorkspaceProxy{
460460
ID: p.ID,
461461
Name: p.Name,
462-
DisplayName: p.DisplayName,
463462
Icon: p.Icon,
464463
URL: p.Url,
465464
WildcardHostname: p.WildcardHostname,

0 commit comments

Comments
 (0)