-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
refactor(proxy/auth): cherry-pick #29343 into patch/v1.87.0rc1 #29362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -213,7 +213,7 @@ async def test_permission_inheritance_edge_cases(self): | |||||||||||||||||||
| # Test case 2: Authorization header present (fallback) | ||||||||||||||||||||
| ( | ||||||||||||||||||||
| [(b"authorization", b"Bearer test-auth-token")], | ||||||||||||||||||||
| "Bearer test-auth-token", | ||||||||||||||||||||
| "test-auth-token", | ||||||||||||||||||||
| None, | ||||||||||||||||||||
| {}, | ||||||||||||||||||||
| ), | ||||||||||||||||||||
|
|
@@ -674,7 +674,9 @@ async def mock_user_api_key_auth(api_key, request): | |||||||||||||||||||
| ) = await MCPRequestHandler.process_mcp_request(scope) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Should succeed with the LiteLLM key from Authorization header | ||||||||||||||||||||
| assert auth_result.api_key == "Bearer sk-litellm-valid-key" | ||||||||||||||||||||
| from litellm.proxy.utils import hash_token | ||||||||||||||||||||
|
|
||||||||||||||||||||
| assert auth_result.api_key == hash_token("sk-litellm-valid-key") | ||||||||||||||||||||
|
Comment on lines
676
to
+679
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||
| mock_auth.assert_called_once() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| async def test_non_auth_http_exception_still_raises(self): | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return normalizedreturns the prefix-stripped token for keys that are neithersk-*nor JWT. For an opaqueBearer <token>value that matches neither case, the old code returnedBearer <token>verbatim (unhashed), while the new code returns<token>(also unhashed). Both are technically correct — the pre-existing behaviour was already not hashing this class of input — but a clarifying comment here would make the intentional non-hashing explicit for future readers.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!