Jeremiah Lowin commited on
Commit
d215186
·
1 Parent(s): 5c6cd30

Update bearer.py

Browse files
src/fastmcp/server/auth/providers/bearer.py CHANGED
@@ -399,22 +399,20 @@ class BearerAuthProvider(OAuthProvider):
399
  return None
400
 
401
  def _extract_scopes(self, claims: dict[str, Any]) -> list[str]:
402
- """Extract scopes from JWT claims. Supports both 'scope' and 'scp' claims."""
403
- # Check for 'scope' claim first (standard OAuth2 claim)
404
- scope_claim = claims.get("scope")
405
- if scope_claim is not None:
406
- if isinstance(scope_claim, str):
407
- return scope_claim.split()
408
- elif isinstance(scope_claim, list):
409
- return scope_claim
410
-
411
- # Check for 'scp' claim (used by some Identity Providers)
412
- scp_claim = claims.get("scp")
413
- if scp_claim is not None:
414
- if isinstance(scp_claim, str):
415
- return scp_claim.split()
416
- elif isinstance(scp_claim, list):
417
- return scp_claim
418
 
419
  return []
420
 
 
399
  return None
400
 
401
  def _extract_scopes(self, claims: dict[str, Any]) -> list[str]:
402
+ """
403
+ Extract scopes from JWT claims. Supports both 'scope' and 'scp'
404
+ claims.
405
+
406
+ Checks the `scope` claim first (standard OAuth2 claim), then the `scp`
407
+ claim (used by some Identity Providers).
408
+ """
409
+
410
+ for claim in ["scope", "scp"]:
411
+ if claim in claims:
412
+ if isinstance(claims[claim], str):
413
+ return claims[claim].split()
414
+ elif isinstance(claims[claim], list):
415
+ return claims[claim]
 
 
416
 
417
  return []
418