From 9619fe224c96d0c4a060e83badbf95b6bd69a0ac Mon Sep 17 00:00:00 2001 From: Toby Allen Date: Sun, 7 Jan 2018 14:44:49 +0000 Subject: [PATCH] add basicauth {user} to replacer (#1979) --- caddyhttp/basicauth/basicauth.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/caddyhttp/basicauth/basicauth.go b/caddyhttp/basicauth/basicauth.go index 1bb71f25..0496c3e1 100644 --- a/caddyhttp/basicauth/basicauth.go +++ b/caddyhttp/basicauth/basicauth.go @@ -79,6 +79,10 @@ func (a BasicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error // user; this replaces the request with a wrapped instance r = r.WithContext(context.WithValue(r.Context(), httpserver.RemoteUserCtxKey, username)) + + // Provide username to be used in log by replacer + repl := httpserver.NewReplacer(r, nil, "-") + repl.Set("user", username) } }