Spaces:
Running
Running
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 |
-
"""
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 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 |
|