diff options
author | Francis Lavoie <lavofr@gmail.com> | 2021-12-02 15:26:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 13:26:24 -0700 |
commit | 5bf0adad8748e96e10529d5fc5777afc9236a7b5 (patch) | |
tree | b26d766d1686f39d5d43847d4742782fa5524c4f /modules/caddyhttp/push | |
parent | 8e5aafa5cdb0bd6ad062014172ed21fdc1012cc1 (diff) |
caddyhttp: Make logging of credential headers opt-in (#4438)
Diffstat (limited to 'modules/caddyhttp/push')
-rw-r--r-- | modules/caddyhttp/push/handler.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/caddyhttp/push/handler.go b/modules/caddyhttp/push/handler.go index a89c0cd..75442be 100644 --- a/modules/caddyhttp/push/handler.go +++ b/modules/caddyhttp/push/handler.go @@ -69,6 +69,8 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt } repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer) + server := r.Context().Value(caddyhttp.ServerCtxKey).(*caddyhttp.Server) + shouldLogCredentials := server.Logs != nil && server.Logs.ShouldLogCredentials // create header for push requests hdr := h.initializePushHeaders(r, repl) @@ -79,7 +81,10 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt zap.String("uri", r.RequestURI), zap.String("push_method", resource.Method), zap.String("push_target", resource.Target), - zap.Object("push_headers", caddyhttp.LoggableHTTPHeader(hdr))) + zap.Object("push_headers", caddyhttp.LoggableHTTPHeader{ + Header: hdr, + ShouldLogCredentials: shouldLogCredentials, + })) err := pusher.Push(repl.ReplaceAll(resource.Target, "."), &http.PushOptions{ Method: resource.Method, Header: hdr, |