fix(oauth): fix invalid_scope and invalid_token errors for user OAuth clients

Three bugs fixed for social-login users connecting Claude.ai via OAuth:

1. User OAuth clients now allow 'admin' scope by default — previously
   defaulted to ['read', 'write'], causing invalid_scope when Claude.ai
   requests 'admin' scope during authorization.

2. Fix JWT tokens with 'aud' claim being rejected by middleware — when
   Claude.ai sends RFC 8707 resource parameter, the issued JWT gets an
   aud claim. validate_access_token() now sets verify_aud=False to
   prevent PyJWT InvalidAudienceError from silently marking valid tokens
   as invalid in _is_valid_token().

3. Fix NameError in user_mcp_handler tools/call scope check — key_info
   was only defined in the mhu_ auth path but referenced in tools/call
   for both paths. Replaced with key_scopes variable set by both mhu_
   and JWT auth paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
airano
2026-02-26 00:37:43 +03:30
parent 4a5381d765
commit a806671e2d
3 changed files with 8 additions and 2 deletions

View File

@@ -139,6 +139,7 @@ class TokenManager:
"verify_signature": True,
"verify_exp": True,
"verify_nbf": True,
"verify_aud": False, # Server is the resource server; no external aud check needed
},
)