proxy: fix WS Authorization Header being sent with the wrong format
This commit is contained in:
		| @ -15,7 +15,6 @@ class EventSerializer(ModelSerializer): | |||||||
|             "pk", |             "pk", | ||||||
|             "user", |             "user", | ||||||
|             "action", |             "action", | ||||||
|             "date", |  | ||||||
|             "app", |             "app", | ||||||
|             "context", |             "context", | ||||||
|             "client_ip", |             "client_ip", | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ package server | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"crypto/tls" | 	"crypto/tls" | ||||||
|  | 	"encoding/base64" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/url" | 	"net/url" | ||||||
| @ -19,8 +20,10 @@ func (ac *APIController) initWS(pbURL url.URL, outpostUUID strfmt.UUID) { | |||||||
| 	pathTemplate := "%s://%s/ws/outpost/%s/" | 	pathTemplate := "%s://%s/ws/outpost/%s/" | ||||||
| 	scheme := strings.ReplaceAll(pbURL.Scheme, "http", "ws") | 	scheme := strings.ReplaceAll(pbURL.Scheme, "http", "ws") | ||||||
|  |  | ||||||
|  | 	authHeader := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("Basic :%s", ac.token))) | ||||||
|  |  | ||||||
| 	header := http.Header{ | 	header := http.Header{ | ||||||
| 		"Authorization": []string{ac.token}, | 		"Authorization": []string{authHeader}, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	value, set := os.LookupEnv("PASSBOOK_INSECURE") | 	value, set := os.LookupEnv("PASSBOOK_INSECURE") | ||||||
| @ -69,7 +72,7 @@ func (ac *APIController) startWSHandler() { | |||||||
| 	for { | 	for { | ||||||
| 		if !ac.wsConn.IsConnected() { | 		if !ac.wsConn.IsConnected() { | ||||||
| 			notConnectedWait := time.Duration(notConnectedBackoff) * time.Second | 			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) | 			time.Sleep(notConnectedWait) | ||||||
| 			notConnectedBackoff += notConnectedBackoff | 			notConnectedBackoff += notConnectedBackoff | ||||||
| 			continue | 			continue | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer