Skip to content

Commit 8e1665a

Browse files
authored
Remove client info modifications (#1620)
1 parent 9c5c4f5 commit 8e1665a

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/fastmcp/server/auth/oauth_proxy.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,6 @@ async def register_client(self, client_info: OAuthClientInformationFull) -> None
419419
allowed_redirect_uri_patterns=self._allowed_client_redirect_uris,
420420
)
421421

422-
# Modify the client_info object in place (framework ignores return values)
423-
client_info.client_id = upstream_id
424-
client_info.client_secret = upstream_secret
425-
client_info.token_endpoint_auth_method = "none"
426-
427-
# Ensure correct grant types
428-
if not client_info.grant_types:
429-
client_info.grant_types = ["authorization_code", "refresh_token"]
430-
431422
# Store the ProxyDCRClient using the upstream ID
432423
self._clients[upstream_id] = proxy_client
433424

tests/server/auth/test_oauth_proxy.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_revocation_disabled_without_endpoint(self, jwt_verifier):
159159
assert proxy._upstream_revocation_endpoint is None
160160

161161
async def test_register_client(self, oauth_proxy):
162-
"""Test client registration always uses upstream credentials."""
162+
"""Test client registration stores ProxyDCRClient without modifying original."""
163163
client_info = OAuthClientInformationFull(
164164
client_id="original-client-id",
165165
client_secret="original-secret",
@@ -170,20 +170,19 @@ async def test_register_client(self, oauth_proxy):
170170

171171
await oauth_proxy.register_client(client_info)
172172

173-
# Verify client was modified to use upstream credentials
174-
assert client_info.client_id == "test-client-id"
175-
assert client_info.client_secret == "test-client-secret"
176-
assert client_info.token_endpoint_auth_method == "none"
177-
assert "authorization_code" in client_info.grant_types
178-
# refresh_token is only added if grant_types was empty
173+
assert client_info.client_id == "original-client-id"
174+
assert client_info.client_secret == "original-secret"
175+
assert client_info.token_endpoint_auth_method == "client_secret_post"
176+
assert client_info.grant_types == ["authorization_code"]
179177

180-
# Verify client was stored
178+
# Verify ProxyDCRClient was stored with upstream credentials
181179
stored_client = oauth_proxy._clients.get("test-client-id")
182180
assert stored_client is not None
183181
assert stored_client.client_id == "test-client-id"
182+
assert stored_client.client_secret == "test-client-secret"
184183

185184
async def test_register_client_empty_grant_types(self, oauth_proxy):
186-
"""Test client registration adds grant types when empty."""
185+
"""Test client registration with empty grant types."""
187186
client_info = OAuthClientInformationFull(
188187
client_id="original-client-id",
189188
client_secret="original-secret",
@@ -193,8 +192,12 @@ async def test_register_client_empty_grant_types(self, oauth_proxy):
193192

194193
await oauth_proxy.register_client(client_info)
195194

196-
# Should add both authorization_code and refresh_token
197-
assert client_info.grant_types == ["authorization_code", "refresh_token"]
195+
assert client_info.grant_types == []
196+
197+
# Verify stored ProxyDCRClient has proper grant types
198+
stored_client = oauth_proxy._clients.get("test-client-id")
199+
assert stored_client is not None
200+
assert stored_client.grant_types == ["authorization_code", "refresh_token"]
198201

199202
async def test_get_client_existing(self, oauth_proxy):
200203
"""Test getting an existing registered client."""

0 commit comments

Comments
 (0)