- Notifications
You must be signed in to change notification settings - Fork1.1k
chore: make authz recorder opt in#20310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
8437c79610a7eae87e50e5f58bef452b6090235695File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,6 +4,7 @@ package httpmw | ||
| import ( | ||
| "net/http" | ||
| "strconv" | ||
| "github.com/go-chi/chi/v5" | ||
| @@ -39,14 +40,24 @@ func AsAuthzSystem(mws ...func(http.Handler) http.Handler) func(http.Handler) ht | ||
| } | ||
| } | ||
| // RecordAuthzChecks enables recording all 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. | ||
| // | ||
| // Can either be toggled on by a deployment wide configuration value, or opt-in on | ||
| // a per-request basis by setting the `x-record-authz-checks` header to a truthy value. | ||
| // | ||
| // Requires using a Recorder Authorizer. | ||
| // | ||
| //nolint:revive | ||
| func RecordAuthzChecks(always bool) func(next http.Handler) http.Handler { | ||
| return func(next http.Handler) http.Handler { | ||
| return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | ||
| if enabled, _ := strconv.ParseBool(r.Header.Get("x-record-authz-checks")); enabled || always { | ||
| r = r.WithContext(rbac.WithAuthzCheckRecorder(r.Context())) | ||
| } | ||
| next.ServeHTTP(rw, r) | ||
| }) | ||
| } | ||
Comment on lines +54 to +62 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. minor suggestion (that maybe would fix what the linter is complaining about?): if but this is also only enabled in dev builds so the performance gain wouldn't really matter. just a thought! | ||
| } | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.