This commit is contained in:
Markos Gogoulos
2026-04-27 13:17:17 +03:00
parent 430d2b4954
commit c8adc02236
2 changed files with 4 additions and 10 deletions
-1
View File
@@ -14,7 +14,6 @@ urlpatterns = [
path('jwks/', views.JWKSView.as_view(), name='jwks'), path('jwks/', views.JWKSView.as_view(), name='jwks'),
path('public-key/', views.PublicKeyPEMView.as_view(), name='public_key_pem'), path('public-key/', views.PublicKeyPEMView.as_view(), name='public_key_pem'),
path('select-media/', deep_linking.SelectMediaView.as_view(), name='select_media'), path('select-media/', deep_linking.SelectMediaView.as_view(), name='select_media'),
path('media-not-found/', views.MediaNotFoundView.as_view(), name='media_not_found'),
path('my-media/', views.MyMediaLTIView.as_view(), name='my_media'), path('my-media/', views.MyMediaLTIView.as_view(), name='my_media'),
path('embed/<str:friendly_token>/', views.EmbedMediaLTIView.as_view(), name='embed_media'), path('embed/<str:friendly_token>/', views.EmbedMediaLTIView.as_view(), name='embed_media'),
] ]
+4 -9
View File
@@ -381,6 +381,9 @@ class LaunchView(View):
redirect_url = self.determine_redirect(launch_data, resource_link_obj) redirect_url = self.determine_redirect(launch_data, resource_link_obj)
if redirect_url is None:
return HttpResponse('This media no longer exists', status=404, content_type='text/plain; charset=utf-8')
# Use HTML meta refresh instead of HTTP redirect to ensure session cookie is sent # Use HTML meta refresh instead of HTTP redirect to ensure session cookie is sent
# In cross-site/iframe contexts, HTTP 302 redirects may not preserve session cookies # In cross-site/iframe contexts, HTTP 302 redirects may not preserve session cookies
html_content = f""" html_content = f"""
@@ -459,7 +462,7 @@ class LaunchView(View):
base_url = reverse('lti:embed_media', args=[media.friendly_token]) base_url = reverse('lti:embed_media', args=[media.friendly_token])
return self.build_url_with_embed_params(base_url, embed_params) return self.build_url_with_embed_params(base_url, embed_params)
except Media.DoesNotExist: except Media.DoesNotExist:
return reverse('lti:media_not_found') return None
my_media_url = reverse('lti:my_media') + '?mode=lms_embed_mode' my_media_url = reverse('lti:my_media') + '?mode=lms_embed_mode'
if custom.get('embed_share_media') == '0': if custom.get('embed_share_media') == '0':
@@ -677,14 +680,6 @@ class PublicKeyPEMView(View):
) )
@method_decorator(xframe_options_exempt, name='dispatch')
class MediaNotFoundView(View):
"""Shown when a media token from an LTI launch no longer exists."""
def get(self, request):
return HttpResponse('This media no longer exists', status=404, content_type='text/plain; charset=utf-8')
@method_decorator(xframe_options_exempt, name='dispatch') @method_decorator(xframe_options_exempt, name='dispatch')
class MyMediaLTIView(View): class MyMediaLTIView(View):
""" """