forked from phoenix/litellm-mirror
fix(handle_jwt.py): support scopes being a list
allow scopes in jwt to be a list, not just a space-separated string
This commit is contained in:
parent
5aa1c10929
commit
f1b1640a31
1 changed files with 9 additions and 2 deletions
|
@ -134,8 +134,15 @@ class JWTHandler:
|
||||||
|
|
||||||
def get_scopes(self, token: dict) -> list:
|
def get_scopes(self, token: dict) -> list:
|
||||||
try:
|
try:
|
||||||
|
if isinstance(token["scope"], str):
|
||||||
# Assuming the scopes are stored in 'scope' claim and are space-separated
|
# Assuming the scopes are stored in 'scope' claim and are space-separated
|
||||||
scopes = token["scope"].split()
|
scopes = token["scope"].split()
|
||||||
|
elif isinstance(token["scope"], list):
|
||||||
|
scopes = token["scope"]
|
||||||
|
else:
|
||||||
|
raise Exception(
|
||||||
|
f"Unmapped scope type - {type(token['scope'])}. Supported types - list, str."
|
||||||
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
scopes = []
|
scopes = []
|
||||||
return scopes
|
return scopes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue