mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 21:44:18 +02:00
Add scope validation to InMemoryOAuthProvider and remove debug breakpoint
- Add scope validation to InMemoryOAuthProvider.register_client() to match MCP SDK behavior - Ensures unit tests catch scope-related bugs like the MCP SDK 1.21.1 issue - Remove debug breakpoint from OAuth client redirect_handler
This commit is contained in:
parent
a98838c158
commit
1895f86323
1 changed files with 14 additions and 0 deletions
|
|
@ -66,6 +66,20 @@ class InMemoryOAuthProvider(OAuthProvider):
|
|||
return self.clients.get(client_id)
|
||||
|
||||
async def register_client(self, client_info: OAuthClientInformationFull) -> None:
|
||||
# Validate scopes against valid_scopes if configured (matches MCP SDK behavior)
|
||||
if (
|
||||
client_info.scope is not None
|
||||
and self.client_registration_options is not None
|
||||
and self.client_registration_options.valid_scopes is not None
|
||||
):
|
||||
requested_scopes = set(client_info.scope.split())
|
||||
valid_scopes = set(self.client_registration_options.valid_scopes)
|
||||
invalid_scopes = requested_scopes - valid_scopes
|
||||
if invalid_scopes:
|
||||
raise ValueError(
|
||||
f"Requested scopes are not valid: {', '.join(invalid_scopes)}"
|
||||
)
|
||||
|
||||
if client_info.client_id in self.clients:
|
||||
# As per RFC 7591, if client_id is already known, it's an update.
|
||||
# For this simple provider, we'll treat it as re-registration.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue