Skip to content

Commit ac8f9df

Browse files
committed
fix build errors
1 parent 032338f commit ac8f9df

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

coderd/coderd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ func New(options *Options) *API {
398398
tracing.StatusWriterMiddleware,
399399
tracing.Middleware(api.TracerProvider),
400400
httpmw.AttachRequestID,
401-
httpmw.AttachAuthzCache,
402401
httpmw.ExtractRealIP(api.RealIPConfig),
403402
httpmw.Logger(api.Logger),
404403
httpmw.Prometheus(options.PrometheusRegistry),

coderd/httpmw/authz.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/go-chi/chi/v5"
77

88
"github.com/coder/coder/coderd/database/dbauthz"
9-
"github.com/coder/coder/coderd/rbac"
109
)
1110

1211
// AsAuthzSystem is a chained handler that temporarily sets the dbauthz context
@@ -36,16 +35,3 @@ func AsAuthzSystem(mws ...func(http.Handler) http.Handler) func(http.Handler) ht
3635
})
3736
}
3837
}
39-
40-
// AttachAuthzCache enables the authz cache for the authorizer. All rbac checks will
41-
// run against the cache, meaning duplicate checks will not be performed.
42-
//
43-
// Note the cache is safe for multiple actors. So mixing user and system checks
44-
// is ok.
45-
func AttachAuthzCache(next http.Handler) http.Handler {
46-
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
47-
ctx := rbac.WithCacheCtx(r.Context())
48-
49-
next.ServeHTTP(rw, r.WithContext(ctx))
50-
})
51-
}

coderd/rbac/authz_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,29 +312,28 @@ func BenchmarkCacher(b *testing.B) {
312312
func TestCacher(t *testing.T) {
313313
t.Parallel()
314314

315-
t.Run("EmptyCacheCtx", func(t *testing.T) {
315+
t.Run("NoCache", func(t *testing.T) {
316316
t.Parallel()
317317

318318
ctx := context.Background()
319319
rec := &coderdtest.RecordingAuthorizer{
320320
Wrapped: &coderdtest.FakeAuthorizer{AlwaysReturn: nil},
321321
}
322-
authz := rbac.Cacher(rec)
323322
subj, obj, action := coderdtest.RandomRBACSubject(), coderdtest.RandomRBACObject(), coderdtest.RandomRBACAction()
324323

325324
// Two identical calls
326-
_ = authz.Authorize(ctx, subj, action, obj)
327-
_ = authz.Authorize(ctx, subj, action, obj)
325+
_ = rec.Authorize(ctx, subj, action, obj)
326+
_ = rec.Authorize(ctx, subj, action, obj)
328327

329328
// Yields two calls to the wrapped Authorizer
330329
rec.AssertActor(t, subj, rec.Pair(action, obj), rec.Pair(action, obj))
331330
require.NoError(t, rec.AllAsserted(), "all assertions should have been made")
332331
})
333332

334-
t.Run("CacheCtx", func(t *testing.T) {
333+
t.Run("Cache", func(t *testing.T) {
335334
t.Parallel()
336335

337-
ctx := rbac.WithCacheCtx(context.Background())
336+
ctx := context.Background()
338337
rec := &coderdtest.RecordingAuthorizer{
339338
Wrapped: &coderdtest.FakeAuthorizer{AlwaysReturn: nil},
340339
}
@@ -353,7 +352,7 @@ func TestCacher(t *testing.T) {
353352
t.Run("MultipleSubjects", func(t *testing.T) {
354353
t.Parallel()
355354

356-
ctx := rbac.WithCacheCtx(context.Background())
355+
ctx := context.Background()
357356
rec := &coderdtest.RecordingAuthorizer{
358357
Wrapped: &coderdtest.FakeAuthorizer{AlwaysReturn: nil},
359358
}

0 commit comments

Comments
 (0)