From f5f9a7beac4c8e7db050d834686183baad534261 Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Sun, 28 Dec 2025 15:14:14 +0200 Subject: [PATCH] this --- lti/views.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lti/views.py b/lti/views.py index 8a0b9b83..833cc06b 100644 --- a/lti/views.py +++ b/lti/views.py @@ -128,8 +128,35 @@ class OIDCLoginView(View): logger.info(f"OIDC redirecting to: {redirect_url}") if not redirect_url: - print("ERROR: Empty redirect URL!", flush=True) - return JsonResponse({'error': 'Failed to generate OIDC redirect URL'}, status=500) + print("PyLTI1p3 redirect failed, building URL manually...", flush=True) + # Manual OIDC redirect construction + import uuid + from urllib.parse import urlencode + + state = str(uuid.uuid4()) + nonce = str(uuid.uuid4()) + + # Store state and nonce in session + session_service.save_launch_data(f'state-{state}', {'target_link_uri': target_link_uri, 'nonce': nonce}) + + # Build redirect URL + params = { + 'iss': iss, + 'client_id': client_id, + 'login_hint': login_hint, + 'target_link_uri': target_link_uri, + 'lti_message_hint': lti_message_hint, + 'nonce': nonce, + 'state': state, + 'redirect_uri': target_link_uri, + 'response_type': 'id_token', + 'response_mode': 'form_post', + 'scope': 'openid', + 'prompt': 'none', + } + + redirect_url = f"{platform.auth_login_url}?{urlencode(params)}" + print(f"Manually built redirect URL: {redirect_url}", flush=True) return HttpResponseRedirect(redirect_url) except Exception as e: