]> cat aescling's git repositories - mastodon.git/commitdiff
Use Sec-WebSocket-Protocol instead of query string to pass WebSocket token
authorThibaut Girka <thib@sitedethib.com>
Fri, 17 May 2019 18:52:58 +0000 (20:52 +0200)
committerThibaut Girka <thib@sitedethib.com>
Fri, 24 May 2019 14:08:09 +0000 (16:08 +0200)
Inspired by https://github.com/kubevirt/kubevirt/issues/1242

app/javascript/flavours/glitch/util/stream.js

index 306a068b7a073826fb77b58e20a6481c52ec1704..c4642344fc1191b2bbcea028228fe6b4e0c081d6 100644 (file)
@@ -71,11 +71,7 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
 export default function getStream(streamingAPIBaseURL, accessToken, stream, { connected, received, disconnected, reconnected }) {
   const params = [ `stream=${stream}` ];
 
-  if (accessToken !== null) {
-    params.push(`access_token=${accessToken}`);
-  }
-
-  const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`);
+  const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
 
   ws.onopen      = connected;
   ws.onmessage   = e => received(JSON.parse(e.data));