Fix scope cannot be determined when the access token cannot be decoded
All checks were successful
/ build (push) Successful in 5s
/ test (push) Successful in 6s

This commit is contained in:
phil 2025-02-23 16:37:47 +01:00
parent f6a84fd3aa
commit 850db9f590

View file

@ -123,19 +123,20 @@ async def home(
try:
access_token_parsed = provider.decode(token["access_token"], verify_signature=False)
context["access_token_parsed"] = access_token_parsed
context["access_token_scope"] = access_token_parsed.get("scope")
except PyJWTError as err:
access_token_parsed = {"Cannot parse": err.__class__.__name__}
context["access_token_parsed"] = {"Cannot parse": err.__class__.__name__}
context["access_token_scope"] = None
try:
id_token_parsed = provider.decode(token["id_token"], verify_signature=False)
context["id_token_parsed"] = id_token_parsed
except PyJWTError as err:
id_token_parsed = {"Cannot parse": err.__class__.__name__}
context["id_token_parsed"] = {"Cannot parse": err.__class__.__name__}
try:
refresh_token_parsed = provider.decode(token["refresh_token"], verify_signature=False)
context["refresh_token_parsed"] = refresh_token_parsed
except PyJWTError as err:
refresh_token_parsed = {"Cannot parse": err.__class__.__name__}
context["access_token_scope"] = access_token_parsed.get("scope")
context["refresh_token_parsed"] = {"Cannot parse": err.__class__.__name__}
context["resources"] = registry.resources
context["resource_providers"] = provider.resource_providers
return templates.TemplateResponse(name="home.html", request=request, context=context)