From 36e095671cff900aa1376aa0634569ac0639957b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 18 Oct 2020 13:46:03 +0200 Subject: [PATCH] proxy: fix WS Authorization Header being sent with the wrong format --- passbook/audit/api.py | 1 - proxy/pkg/server/api_ws.go | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/passbook/audit/api.py b/passbook/audit/api.py index eafde6f4d..0208935b5 100644 --- a/passbook/audit/api.py +++ b/passbook/audit/api.py @@ -15,7 +15,6 @@ class EventSerializer(ModelSerializer): "pk", "user", "action", - "date", "app", "context", "client_ip", diff --git a/proxy/pkg/server/api_ws.go b/proxy/pkg/server/api_ws.go index 0266413df..8c6c42f40 100644 --- a/proxy/pkg/server/api_ws.go +++ b/proxy/pkg/server/api_ws.go @@ -2,6 +2,7 @@ package server import ( "crypto/tls" + "encoding/base64" "fmt" "net/http" "net/url" @@ -19,8 +20,10 @@ func (ac *APIController) initWS(pbURL url.URL, outpostUUID strfmt.UUID) { pathTemplate := "%s://%s/ws/outpost/%s/" scheme := strings.ReplaceAll(pbURL.Scheme, "http", "ws") + authHeader := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("Basic :%s", ac.token))) + header := http.Header{ - "Authorization": []string{ac.token}, + "Authorization": []string{authHeader}, } value, set := os.LookupEnv("PASSBOOK_INSECURE") @@ -69,7 +72,7 @@ func (ac *APIController) startWSHandler() { for { if !ac.wsConn.IsConnected() { notConnectedWait := time.Duration(notConnectedBackoff) * time.Second - ac.logger.WithField("loop", "ws-handler").WithField("wait", notConnectedWait).Info("Not connected loop") + ac.logger.WithField("loop", "ws-handler").WithField("wait", notConnectedWait).Info("Not connected, trying again...") time.Sleep(notConnectedWait) notConnectedBackoff += notConnectedBackoff continue