This commit is contained in:
Markos Gogoulos
2025-12-30 18:38:07 +02:00
parent d3c858173f
commit 5070050fa4
2 changed files with 46 additions and 15 deletions

View File

@@ -158,11 +158,25 @@ class LaunchView(View):
unverified = jwt.decode(id_token, options={"verify_signature": False})
iss = unverified.get('iss')
aud = unverified.get('aud')
try:
platform = LTIPlatform.objects.get(platform_id=iss, client_id=aud)
except LTIPlatform.DoesNotExist:
raise
aud = unverified.get('aud') # Can be a string or a list
platform = None
if isinstance(aud, list):
# If aud is a list, find a platform where the client_id is in the list
platforms = LTIPlatform.objects.filter(platform_id=iss, client_id__in=aud)
if platforms.count() == 1:
platform = platforms.first()
elif platforms.count() > 1:
raise LtiException(f"Multiple platforms found for issuer '{iss}' and client_ids '{aud}'")
else:
# If aud is a string, find it directly
try:
platform = LTIPlatform.objects.get(platform_id=iss, client_id=aud)
except LTIPlatform.DoesNotExist:
pass # Platform will be None
if not platform:
raise LtiException(f"Platform not found for issuer '{iss}' and client_id(s) '{aud}'")
tool_config = DjangoToolConfig.from_platform(platform)