From c2bd89997b1b676c1d4f4a8761dfa730d2a96baa Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sat, 19 Aug 2023 21:02:26 -0600 Subject: [PATCH] Disable noisy log warning --- util/http.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/util/http.go b/util/http.go index 1bfd1a2b..2188feb3 100644 --- a/util/http.go +++ b/util/http.go @@ -4,22 +4,18 @@ import ( "net/http" "net/url" "strings" - - "github.com/sirupsen/logrus" ) func GetAccessTokenFromRequest(request *http.Request) string { token := request.Header.Get("Authorization") if token != "" { - if !strings.HasPrefix(token, "Bearer") { - logrus.Warn("Invalid Authorization header observed: expected a Bearer token, got something else") + if !strings.HasPrefix(token, "Bearer ") { // including space + // It's probably an X-Matrix authentication header (federation) + //logrus.Warn("Invalid Authorization header observed: expected a Bearer token, got something else") return "" } - if len(token) > 7 { - // "Bearer " - return token[7:] - } + return token[len("Bearer "):] // including space } return request.URL.Query().Get("access_token")