mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-01-20 15:22:58 -05:00
wtv
This commit is contained in:
24
lti/views.py
24
lti/views.py
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user