Repository: traefik/traefik (language: go)

Issue:
ip whitelist, request rejected, avoid logging auth headers?
### Welcome!

- [X] Yes, I've searched similar issues on [GitHub](https://github.com/traefik/traefik/issues) and didn't find any.
- [X] Yes, I've searched similar issues on the [Traefik community forum](https://community.traefik.io) and didn't find any.

### What did you expect to see?

I'm using IP whitelisting w/ Traefik and when a request is rejected and logged, the full set of headers is also logged, including the authentication. Looking at the code I don't see a way to avoid this? Is there any configuration for this or can one be added to drop the headers?

https://github.com/traefik/traefik/blob/master/pkg/middlewares/ipwhitelist/ip_whitelist.go#L68


Discussion / hints:

Fix patch:
diff --git a/pkg/middlewares/ipwhitelist/ip_whitelist.go b/pkg/middlewares/ipwhitelist/ip_whitelist.go
index 1f57455249..dde042b425 100644
--- a/pkg/middlewares/ipwhitelist/ip_whitelist.go
+++ b/pkg/middlewares/ipwhitelist/ip_whitelist.go
@@ -63,15 +63,16 @@ func (wl *ipWhiteLister) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
 	ctx := middlewares.GetLoggerCtx(req.Context(), wl.name, typeName)
 	logger := log.FromContext(ctx)
 
-	err := wl.whiteLister.IsAuthorized(wl.strategy.GetIP(req))
+	clientIP := wl.strategy.GetIP(req)
+	err := wl.whiteLister.IsAuthorized(clientIP)
 	if err != nil {
-		logMessage := fmt.Sprintf("rejecting request %+v: %v", req, err)
-		logger.Debug(logMessage)
-		tracing.SetErrorWithEvent(req, logMessage)
+		msg := fmt.Sprintf("Rejecting IP %s: %v", clientIP, err)
+		logger.Debug(msg)
+		tracing.SetErrorWithEvent(req, msg)
 		reject(ctx, rw)
 		return
 	}
-	logger.Debugf("Accept %s: %+v", wl.strategy.GetIP(req), req)
+	logger.Debugf("Accepting IP %s", clientIP)
 
 	wl.next.ServeHTTP(rw, req)
 }


Test patch: