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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user