proxy: fix WS Authorization Header being sent with the wrong format

This commit is contained in:
Jens Langhammer 2020-10-18 13:46:03 +02:00
parent 1088b947a8
commit 36e095671c
2 changed files with 5 additions and 3 deletions

View File

@ -15,7 +15,6 @@ class EventSerializer(ModelSerializer):
"pk",
"user",
"action",
"date",
"app",
"context",
"client_ip",

View File

@ -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