Repository navigation
Conversation
Signed-off-by: khushali9 <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces bearer-token authentication to the OpenAI-compatible ingress by adding an api_key configuration parameter and implementing AuthMiddleware to enforce token checks while bypassing CORS preflight and exempt paths. Feedback suggests updating the middleware ordering tests to assert that AuthMiddleware runs inside CORSMiddleware, ensuring CORS headers are correctly applied to unauthorized responses.
eicherseiji
left a comment
There was a problem hiding this comment.
Thanks for working on this! A few follow-ups:
- Please support the configured
api_keyconsistently across all OpenAI builder entrypoints—standard, DP, PD, and dev—including direct-streaming mode. The standard and DP direct-streaming branches currently return before the key is wired, so the explicit value is silently ignored. Dev accepts it through the sharedLLMServingArgsbut does not forward it, while PD does not expose it at all. Authentication should not depend on which builder is used. - Please run auth inside the CORS and HTTP metrics middleware. With the current LIFO ordering, an auth rejection bypasses both, so cross-origin 401 responses lack CORS headers and rejected requests are not recorded by the HTTP metrics middleware. Metrics reads
user_idafter the inner app returns, so authenticated-user tagging should still work with auth inside it.
Please follow up with me on Ray Slack once these are addressed so we can get this landed.
… inside CORS/metrics Signed-off-by: khushali9 <[email protected]>
@eicherseiji I have addressed your feedback, but i am not able to access or join Ray Slack, the link on Ray' readme seems to take me to https://www.ray.io/join-slack and it later asks for anyscale mail account. It even has gmail as option but that is not working for me to sign in. |
Signed-off-by: khushali9 <[email protected]>
|
@eicherseiji Can you please review this again, and I tried to join slack but the process seem very involved and after filling forms also it is not letting me sign and asking for anyscale domain email, which I dont have. |
|
Thanks for the report and @khushali9 for offering to pick this up. Some context on direction first, then concrete tasks. Direction. We're making direct streaming ( Background. With direct streaming, the Tasks1. Confirm and lock in the current behavior with tests (direct streaming).
2. Fix the middleware order so auth runs before LoRA resolution. 3. Fail loudly on the 4. Document it.
5. Add a KubeRay production recipe.
Out of scope
Suggested PR split: 1+2 (tests + ordering fix), 3, 4, 5. Happy to review. CC @eicherseiji |
|
Thanks a lot @kouroshHakha for guidance , I will take up this work soon. |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
Team, I have been bit busy, someone can take this issue, if not I will take once I have bandwidth. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit a9b5777. Configure here.
| ) | ||
| engine_kwargs = dict(llm_config.engine_kwargs) | ||
| engine_kwargs["api_key"] = [api_key] | ||
| return llm_config.model_copy(update={"engine_kwargs": engine_kwargs}) |
There was a problem hiding this comment.
Stale engine config drops API key
High Severity
_apply_ingress_api_key copies the LLMConfig with an updated engine_kwargs but does not invalidate the cached engine config. get_engine_config snapshots kwargs into frontend_kwargs once, and _prepare_engine_config builds FrontendArgs from that snapshot. A copied stale cache leaves api_key out of FrontendArgs, so vLLM never installs auth on the direct-streaming ingress.
Reviewed by Cursor Bugbot for commit a9b5777. Configure here.


Description
Fixes #66487. VLLM_API_KEY / engine api_key are delivered only to the model-replica process, which the ingress reaches over a DeploymentHandle (RPC) — that process never sits on the HTTP boundary, so it never runs vLLM's HTTP auth. The HTTP boundary is OpenAiIngress, whose FastAPI app installed no auth middleware and referenced VLLM_API_KEY nowhere. Result: a wrong/missing Authorization: Bearer token returned 200 instead of 401. This affects the default (OpenAiIngress) path used by both build_openai_app and build_dp_openai_app.
The RAY_SERVE_LLM_ENABLE_DIRECT_STREAMING path is not affected: it serves vLLM's own FastAPI app (build_app), which already installs vLLM's AuthenticationMiddleware when VLLM_API_KEY is set in the replica. No change needed there.
What changed
Configuration
Testing
Not a duplicate
No open PR addresses #66487 (searched open PRs for the serve-LLM auth area); the issue is unassigned and maintainer-triaged serve/security/llm.
AI assistance was used to analyze and implement this change; I have reviewed every changed line and run the tests above.
🤖 Generated with Claude Opus 4.8