Portal link: send the instance credential as Authorization: Bearer

Not ?token= in the tunnel URL, which access logs keep. The hub has to be
upgraded first; websockets>=14 for additional_headers on the asyncio client.
This commit is contained in:
2026-10-07 09:41:44 +02:00
parent 1424e1e8a8
commit e9c3d0944d
5 changed files with 45 additions and 5 deletions
+5 -2
View File
@@ -191,9 +191,12 @@ class CloudConnector:
import websockets
attached = False
url = f"{config.ws_url}?token={config.token}"
# A header rather than `?token=`, since a URL ends up in access logs.
# A hub from before the header reads only the query: upgrade the hub
# before its instances.
async with websockets.connect(
url,
config.ws_url,
additional_headers={"Authorization": f"Bearer {config.token}"},
max_size=MAX_WS_MESSAGE,
ping_interval=PING_INTERVAL_S,
ping_timeout=PING_TIMEOUT_S,