-
Notifications
You must be signed in to change notification settings - Fork 0
bug: WebSocket connections rejected with 403 despite correct auth exclude path #549
Copy link
Copy link
Closed
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedscope:medium1-3 days of work1-3 days of workspec:human-interactionDESIGN_SPEC Section 13 - Human Interaction LayerDESIGN_SPEC Section 13 - Human Interaction Layerspec:securityDESIGN_SPEC Section 12 - Security & Approval SystemDESIGN_SPEC Section 12 - Security & Approval Systemtype:fixBug fixes and correctionsBug fixes and corrections
Description
Summary
All WebSocket connections to /api/v1/ws?ticket=... are rejected with 403 Forbidden. The WS icon in the dashboard is permanently red. No real-time updates reach the frontend.
Investigation Findings
The ticket-based WS auth flow works partially:
POST /api/v1/auth/ws-ticketsucceeds (200, ticket issued, logged asapi.ws.ticket_issued)WebSocket /api/v1/ws?ticket=...is rejected with 403 before the handler runs- No
api.ws.ticket_invalid,api.ws.connected, or any WS handler log lines appear -- the rejection happens at the Litestar framework level
What was ruled out
- Auth middleware exclude path:
^/api/v1/ws$correctly matchesscope["path"](path without query string). Verified withbuild_exclude_path_pattern-- returnsbypass=Truefor/api/v1/ws. - Router guard:
require_password_changedreturns immediately whenuser is None(line 198-199 ofauth/controller.py). Not the cause. - Channels plugin:
create_ws_route_handlers=False-- plugin doesn't create competing routes. - Route registration:
WebSocketRouteat/api/v1/wsis registered with a validroute_handler. - Nginx proxy: WS connections go directly to backend (port 8000), not through nginx. The 403 is from Litestar/uvicorn.
What needs investigation
The 403 comes from the Litestar ASGI pipeline itself, somewhere between the middleware stack and the WS handler. Possible causes:
- Litestar's internal WS upgrade handling may require a non-None
userscope even when middleware is excluded - The
ScopeType.WEBSOCKETin the auth middleware scopes may cause an unexpected interaction - A Litestar version-specific behavior with WS + auth middleware exclusion
Reproducer
synthorg start
# Open http://localhost:3000 -- WS icon is red
# Backend logs show repeated:
# INFO: 172.18.0.3:NNNNN - "WebSocket /api/v1/ws?ticket=..." 403
# INFO: connection rejected (403 Forbidden)Acceptance Criteria
- WebSocket connections succeed when a valid ticket is provided
- WS handler logs show
api.ws.connectedafter successful ticket validation - Dashboard WS icon turns green
- Real-time events (tasks, agents, budget) flow to the dashboard
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedscope:medium1-3 days of work1-3 days of workspec:human-interactionDESIGN_SPEC Section 13 - Human Interaction LayerDESIGN_SPEC Section 13 - Human Interaction Layerspec:securityDESIGN_SPEC Section 12 - Security & Approval SystemDESIGN_SPEC Section 12 - Security & Approval Systemtype:fixBug fixes and correctionsBug fixes and corrections