From f87772a0d342b10c3f61378a02ed02bb19102ae7 Mon Sep 17 00:00:00 2001 From: Lizzy Thomson Date: Tue, 16 May 2023 09:56:18 -0600 Subject: [PATCH] satellite/console: bug fix for using a API key to retrieve a session Change-Id: I0202f75fb78f42af9e7cb00bb3ac73839340c977 --- satellite/console/consoleweb/consoleapi/auth.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/satellite/console/consoleweb/consoleapi/auth.go b/satellite/console/consoleweb/consoleapi/auth.go index ec60640b1..7505dbd01 100644 --- a/satellite/console/consoleweb/consoleapi/auth.go +++ b/satellite/console/consoleweb/consoleapi/auth.go @@ -132,14 +132,13 @@ func (a *Auth) TokenByAPIKey(w http.ResponseWriter, r *http.Request) { defer mon.Task()(&ctx)(&err) authToken := r.Header.Get("Authorization") - split := strings.Split(authToken, "Bearer ") - if len(split) != 2 { + if !(strings.HasPrefix(authToken, "Bearer ")) { a.log.Info("authorization key format is incorrect. Should be 'Bearer '") a.serveJSONError(w, err) return } - apiKey := split[1] + apiKey := strings.TrimPrefix(authToken, "Bearer ") userAgent := r.UserAgent() ip, err := web.GetRequestIP(r)