Skip to content

fix(terminal): inline WS auth — Header/Query deps don't inject on WS#27

Merged
Leolebleis merged 1 commit intomainfrom
fix/ws-auth-inline
May 3, 2026
Merged

fix(terminal): inline WS auth — Header/Query deps don't inject on WS#27
Leolebleis merged 1 commit intomainfrom
fix/ws-auth-inline

Conversation

@Leolebleis
Copy link
Copy Markdown
Owner

Summary

Brew terminal WS endpoint kept 403'ing despite both `X-API-Key` header and `?api_key=` query being set correctly. Root cause: FastAPI's WebSocket dependency resolver doesn't inject `Header()` or `Query()` into shared deps the same way HTTP does, so the credential never reached `require_api_key` and it always saw both keys as `None`.

Read the credential directly from the WS scope inside the WS handler. HTTP routes are unchanged.

Test plan

  • Full pytest suite passes (373)
  • Lint + type-check clean
  • Post-merge: `docker exec brew curl -i -H 'Connection: Upgrade' ...` should now return 101 (or close cleanly with 1008 if key wrong)

FastAPI's WebSocket dependency resolver doesn't inject Header() or Query()
parameters into shared deps the way HTTP does, so `require_api_key` raised
403 on every WS connection — the credential never reached the dep, even
when set in either the X-API-Key header or ?api_key= query.

Read directly from the WS scope instead. The HTTP routes still go through
the shared dep unchanged.

Also drops require_api_key from the terminal_router include — auth is now
the WS handler's responsibility for this router.
@Leolebleis Leolebleis merged commit ffd2684 into main May 3, 2026
4 checks passed
@Leolebleis Leolebleis deleted the fix/ws-auth-inline branch May 3, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant