mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(mcp): emit the canonical WWW-Authenticate header name in the OAuth challenge
raise_user_oauth_challenge emitted the header lowercase while the sibling raise_public and every resource_metadata (RFC 9728) emitter use the canonical WWW-Authenticate; align it. HTTP header names are case-insensitive on the wire so this is cosmetic for compliant clients, but it keeps the challenge builders consistent and matches RFC 6750.
This commit is contained in:
parent
d2f9917f02
commit
b9a2589124
2 changed files with 4 additions and 4 deletions
|
|
@ -178,5 +178,5 @@ def raise_user_oauth_challenge(server: MCPServer) -> NoReturn:
|
|||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail="Unauthorized",
|
||||
headers={"www-authenticate": f'Bearer resource_metadata="{resource_metadata}"'},
|
||||
headers={"WWW-Authenticate": f'Bearer resource_metadata="{resource_metadata}"'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ def test_raise_user_oauth_challenge_points_at_per_server_prm():
|
|||
exc = exc_info.value
|
||||
assert exc.status_code == 401
|
||||
assert (
|
||||
exc.headers["www-authenticate"]
|
||||
exc.headers["WWW-Authenticate"]
|
||||
== 'Bearer resource_metadata="/.well-known/oauth-protected-resource/mcp/my-srv"'
|
||||
)
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ def test_raise_user_oauth_challenge_includes_server_root_path():
|
|||
):
|
||||
raise_user_oauth_challenge(_server(alias="my-srv"))
|
||||
assert (
|
||||
exc_info.value.headers["www-authenticate"]
|
||||
exc_info.value.headers["WWW-Authenticate"]
|
||||
== 'Bearer resource_metadata="/.well-known/oauth-protected-resource/api/v1/mcp/my-srv"'
|
||||
)
|
||||
|
||||
|
|
@ -219,4 +219,4 @@ def test_raise_user_oauth_challenge_includes_server_root_path():
|
|||
def test_raise_user_oauth_challenge_name_fallback(kwargs, expected_name):
|
||||
with patch(_ROOT_PATH, return_value="/"), pytest.raises(HTTPException) as exc_info:
|
||||
raise_user_oauth_challenge(_server(**kwargs))
|
||||
assert f'/mcp/{expected_name}"' in exc_info.value.headers["www-authenticate"]
|
||||
assert f'/mcp/{expected_name}"' in exc_info.value.headers["WWW-Authenticate"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue