mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
chore: add x-authz-checks debug header when running in dev mode (#16873)
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/rbac"
|
||||
)
|
||||
|
||||
// AsAuthzSystem is a chained handler that temporarily sets the dbauthz context
|
||||
@ -35,3 +36,15 @@ func AsAuthzSystem(mws ...func(http.Handler) http.Handler) func(http.Handler) ht
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// RecordAuthzChecks enables recording all of the authorization checks that
|
||||
// occurred in the processing of a request. This is mostly helpful for debugging
|
||||
// and understanding what permissions are required for a given action.
|
||||
//
|
||||
// Requires using a Recorder Authorizer.
|
||||
func RecordAuthzChecks(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
r = r.WithContext(rbac.WithAuthzCheckRecorder(r.Context()))
|
||||
next.ServeHTTP(rw, r)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user