From be33c64afd2508c598b4f314ae52efe0d8491048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Sat, 22 Jan 2022 17:50:04 +0100 Subject: [PATCH] fix: move invalid token to log field (#1171) * fix: move invalid token to log field * escape invalid token in log field * Update pkg/api/api.go Co-authored-by: Simon Aronsson --- pkg/api/api.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index d0c4a95..2ceaea8 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -2,8 +2,9 @@ package api import ( "fmt" - log "github.com/sirupsen/logrus" "net/http" + + log "github.com/sirupsen/logrus" ) const tokenMissingMsg = "api token is empty or has not been set. exiting" @@ -28,8 +29,6 @@ func (api *API) RequireToken(fn http.HandlerFunc) http.HandlerFunc { auth := r.Header.Get("Authorization") want := fmt.Sprintf("Bearer %s", api.Token) if auth != want { - log.Tracef("Invalid Authorization header \"%s\"", auth) - log.Tracef("Expected Authorization header to be \"%s\"", want) w.WriteHeader(http.StatusUnauthorized) return }