mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
chore: add global caching to rbac (#7439)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
This commit is contained in:
@ -6,7 +6,6 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"github.com/coder/coder/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/coderd/rbac"
|
||||
)
|
||||
|
||||
// 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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// AttachAuthzCache enables the authz cache for the authorizer. All rbac checks will
|
||||
// run against the cache, meaning duplicate checks will not be performed.
|
||||
//
|
||||
// Note the cache is safe for multiple actors. So mixing user and system checks
|
||||
// is ok.
|
||||
func AttachAuthzCache(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := rbac.WithCacheCtx(r.Context())
|
||||
|
||||
next.ServeHTTP(rw, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user