diff --git a/lti/adapters.py b/lti/adapters.py index 5a41dd9d..4c891e98 100644 --- a/lti/adapters.py +++ b/lti/adapters.py @@ -229,8 +229,12 @@ class DjangoToolConfig(ToolConfAbstract): # Set tool's private key for signing (e.g., Deep Linking responses) key_obj = LTIToolKeys.get_or_create_keys() - # Pass the full JWK dict (includes kid) - PyLTI1p3 will handle conversion - registration.set_tool_private_key(key_obj.private_key_jwk) + jwk_obj = jwk.JWK(**key_obj.private_key_jwk) + pem_bytes = jwk_obj.export_to_pem(private_key=True, password=None) + + # Set both the key and kid directly on Registration internal attributes + registration._tool_private_key = pem_bytes.decode('utf-8') + registration._tool_private_key_kid = key_obj.private_key_jwk['kid'] return registration @@ -255,8 +259,12 @@ class DjangoToolConfig(ToolConfAbstract): # Set tool's private key for signing (e.g., Deep Linking responses) key_obj = LTIToolKeys.get_or_create_keys() - # Pass the full JWK dict (includes kid) - PyLTI1p3 will handle conversion - registration.set_tool_private_key(key_obj.private_key_jwk) + jwk_obj = jwk.JWK(**key_obj.private_key_jwk) + pem_bytes = jwk_obj.export_to_pem(private_key=True, password=None) + + # Set both the key and kid directly on Registration internal attributes + registration._tool_private_key = pem_bytes.decode('utf-8') + registration._tool_private_key_kid = key_obj.private_key_jwk['kid'] return registration diff --git a/lti/deep_linking.py b/lti/deep_linking.py index bebb12b9..f60c63b3 100644 --- a/lti/deep_linking.py +++ b/lti/deep_linking.py @@ -144,8 +144,8 @@ class SelectMediaView(View): # Get deep linking settings from original launch data deep_linking_settings = message_launch_data.get('https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings', {}) - # Create DeepLink instance directly - deep_link = DeepLink(registration, deployment_id, deep_linking_settings) + # Create DeepLink instance with tool_config for key retrieval + deep_link = DeepLink(registration, deployment_id, deep_linking_settings, tool_config=tool_config) # Convert content_items to DeepLinkResource objects resources = []