Skip to content

Commit 4f789a7

Browse files
chore: address ruff
1 parent c7e46f3 commit 4f789a7

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/mcp/server/auth/middleware/client_auth.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,20 @@ async def authenticate_request(self, request: Request) -> OAuthClientInformation
6868
match client.token_endpoint_auth_method:
6969
case "client_secret_basic":
7070
if client_credentials.auth_method != "client_secret_basic":
71-
raise AuthenticationError(f"Expected client_secret_basic authentication method, but got {client_credentials.auth_method}")
71+
raise AuthenticationError(
72+
f"Expected client_secret_basic authentication method, but got {client_credentials.auth_method}"
73+
)
7274
case "client_secret_post":
7375
if client_credentials.auth_method != "client_secret_post":
74-
raise AuthenticationError(f"Expected client_secret_post authentication method, but got {client_credentials.auth_method}")
76+
raise AuthenticationError(
77+
f"Expected client_secret_post authentication method, but got {client_credentials.auth_method}"
78+
)
7579
case "none":
7680
pass
7781
case _:
78-
raise AuthenticationError(f"Unsupported auth method: {client.token_endpoint_auth_method}") # pragma: no cover
82+
raise AuthenticationError( # pragma: no cover
83+
f"Unsupported auth method: {client.token_endpoint_auth_method}"
84+
)
7985

8086
# If client from the store expects a secret, validate that the request provides
8187
# that secret
@@ -97,9 +103,9 @@ async def authenticate_request(self, request: Request) -> OAuthClientInformation
97103
async def _get_credentials(self, request: Request) -> ClientCredentials:
98104
"""
99105
Extract client credentials from request, either from form data or Basic auth header.
100-
106+
101107
Basic auth header takes precedence over form data.
102-
108+
103109
Args:
104110
request: The HTTP request containing client credentials
105111
Returns:
@@ -131,7 +137,7 @@ async def _get_credentials(self, request: Request) -> ClientCredentials:
131137
client_id = form_data.get("client_id")
132138
if not client_id:
133139
raise AuthenticationError("Missing client_id")
134-
140+
135141
raw_client_secret = form_data.get("client_secret")
136142
client_secret = str(raw_client_secret) if isinstance(raw_client_secret, str) else None
137143
return ClientCredentials(

tests/server/fastmcp/auth/test_auth_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ async def test_basic_auth_takes_precedence(
13231323

13241324
# Header takes precedence, so this should succeed
13251325
assert response.status_code == 200
1326-
1326+
13271327
@pytest.mark.anyio
13281328
async def test_basic_auth_without_client_id_at_body(
13291329
self, test_client: httpx.AsyncClient, mock_oauth_provider: MockOAuthProvider, pkce_challenge: dict[str, str]

0 commit comments

Comments
 (0)