From 3fabc1c10455a85ee93f94206f33a007c1d0c7a1 Mon Sep 17 00:00:00 2001 From: guwe Date: Sun, 7 Feb 2021 06:36:40 +0000 Subject: [PATCH] Enrich unauthorized logs --- internal/commands/root/mux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/commands/root/mux.go b/internal/commands/root/mux.go index 21e48ad..dc5cd12 100644 --- a/internal/commands/root/mux.go +++ b/internal/commands/root/mux.go @@ -58,14 +58,14 @@ func (s ServeMuxWithAuth) authHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { info, ok, err := s.auth.AuthenticateRequest(req) if err != nil { - log.G(s.ctx).Infof("Unauthorized, err: %s", err) + log.G(s.ctx).Infof("Unauthorized, err: %s, RequestURI:%s, UserAgent:%s", err, req.RequestURI, req.UserAgent()) resp.WriteHeader(http.StatusUnauthorized) resp.Write([]byte("Unauthorized")) return } if !ok { - log.G(s.ctx).Infof("Unauthorized, ok: %t", ok) + log.G(s.ctx).Infof("Unauthorized, ok: %t, RequestURI:%s, UserAgent:%s", ok, req.RequestURI, req.UserAgent()) resp.WriteHeader(http.StatusUnauthorized) resp.Write([]byte("Unauthorized"))