Authenticate sockets by header or one-time ticket instead of ?token=

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-07 08:58:22 +02:00
co-authored by Claude Opus 5.5
parent eb45fb2763
commit 5259b8db0a
21 changed files with 336 additions and 44 deletions
+5 -2
View File
@@ -35,6 +35,7 @@ from fluksio.api.deps import (
get_current_user,
worker_claims,
)
from fluksio.api.socket_auth import socket_token
from fluksio.core import security
from fluksio.flow.remote import (
PROTOCOL,
@@ -240,9 +241,11 @@ def read_runtime() -> str:
async def attach(websocket: WebSocket, token: str = "") -> None:
"""A worker's connection, for as long as it holds.
The token goes in the query string for the same reason the dashboard's
does: a websocket handshake carries no headers of its own.
The token comes as `Authorization: Bearer` on the handshake. `?token=` is
still read for one release, so the engine can be upgraded before its
workers.
"""
token = socket_token(websocket.headers, token=token)
try:
claims = await run_in_threadpool(worker_claims, token)
except InvalidTokenError: