Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolas committed Jan 23, 2025
1 parent 40f777c commit 5107c59
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 79 deletions.
7 changes: 5 additions & 2 deletions lti_auth/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from django.urls import path

from lti_auth.views import LTIConfigView, LTILandingPage, LTIRoutingView, \
LTICourseEnableView
from lti_auth.views import (
LTIConfigView, LTILandingPage, LTIRoutingView,
LTICourseEnableView, LTI1p3JSONConfigView
)
from lti_tool.views import jwks, OIDCLoginInitView


urlpatterns = [
path('config.xml', LTIConfigView.as_view(), {}, 'lti-config'),
path('config.json', LTI1p3JSONConfigView.as_view(), name='lti-1p3-config'),
path('enable/', LTICourseEnableView.as_view(), {}, 'lti-enable-course'),
path('landing/<slug:context>/',
LTILandingPage.as_view(), {}, 'lti-landing-page'),
Expand Down
143 changes: 66 additions & 77 deletions lti_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,101 +127,90 @@ def get_context_data(self, **kwargs):
return ctx


class LTI13JSONConfigView(View):
def get(self, **kwargs):
class LTI1p3JSONConfigView(View):
"""
JSON configuration endpoint for LTI 1.3.
In Canvas LMS, an LTI Developer Key can be created via Manual
Entry, or by URL. This view provides the JSON necessary for URL
configuration in Canvas.
https://canvas.instructure.com/doc/api/file.lti_dev_key_config.html
"""
def get(self, request, *args, **kwargs):
domain = request.get_host()
print(domain)
json_obj = {
"title": "The Best Tool",
"description": "1.3 Test Tool used for documentation purposes.",
"oidc_initiation_url": "https://your.oidc_initiation_url",
"oidc_initiation_urls": {
"eu-west-1": "https://your.eu-specific1.oidc_initiation_url",
"eu-central-1": "https://your.eu-specific2.oidc_initiation_url"
},
"target_link_uri": "https://your.target_link_uri",
"scopes": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly"
'title': settings.LTI_TOOL_CONFIGURATION['title'],
'description': settings.LTI_TOOL_CONFIGURATION['description'],
'oidc_initiation_url': 'https://{}.oidc_initiation_url',
'target_link_uri': 'https://{}.target_link_uri'.format(domain),
'scopes': [
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem',
'https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly'
],
"extensions": [
'extensions': [
{
"domain": "thebesttool.com",
"tool_id": "the-best-tool",
"platform": "canvas.instructure.com",
"privacy_level": "public",
"settings": {
"text": "Launch The Best Tool",
"labels": {
"en": "Launch The Best Tool",
"en-AU": "G'day, Launch The Best Tool",
"es": "Lanzar la mejor herramienta",
"zh-Hans": "启动最佳工具"
'domain': domain,
'tool_id': 'mediathread',
'platform': 'canvas.instructure.com',
'privacy_level': 'public',
'settings': {
'text': 'Launch Mediathread',
'labels': {
'en': 'Launch Mediathread',
},
"icon_url": "https://some.icon.url/tool-level.png",
"selection_height": 800,
"selection_width": 800,
"placements": [
'icon_url': 'https://some.icon.url/tool-level.png',
'selection_height': 800,
'selection_width': 800,
'placements': [
{
"text": "User Navigation Placement",
"icon_url": "https://some.icon.url/my_dashboard.png",
"placement": "user_navigation",
"message_type": "LtiResourceLinkRequest",
"target_link_uri": "https://your.target_link_uri/my_dashboard",
"canvas_icon_class": "icon-lti",
"custom_fields": {
"foo": "$Canvas.user.id"
'text': 'User Navigation Placement',
'icon_url': 'https://some.icon.url/my_dashboard.png',
'placement': 'user_navigation',
'message_type': 'LtiResourceLinkRequest',
'target_link_uri': 'https://your.target_link_uri/my_dashboard',
'canvas_icon_class': 'icon-lti',
'custom_fields': {
'foo': '$Canvas.user.id'
}
},
{
"text": "Editor Button Placement",
"icon_url": "https://some.icon.url/editor_tool.png",
"placement": "editor_button",
"message_type": "LtiDeepLinkingRequest",
"target_link_uri": "https://your.target_link_uri/content_selector",
"selection_height": 500,
"selection_width": 500
'text': 'Editor Button Placement',
'icon_url': 'https://some.icon.url/editor_tool.png',
'placement': 'editor_button',
'message_type': 'LtiDeepLinkingRequest',
'target_link_uri': 'https://your.target_link_uri/content_selector',
'selection_height': 500,
'selection_width': 500
},
{
"text": "Course Navigation Placement",
"icon_url": "https://static.thenounproject.com/png/131630-200.png",
"placement": "course_navigation",
"message_type": "LtiResourceLinkRequest",
"target_link_uri": "https://your.target_link_uri/launch?placement=course_navigation",
"required_permissions": "manage_calendar",
"selection_height": 500,
"selection_width": 500
'text': 'Course Navigation Placement',
'icon_url': 'https://static.thenounproject.com/png/131630-200.png',
'placement': 'course_navigation',
'message_type': 'LtiResourceLinkRequest',
'target_link_uri': 'https://your.target_link_uri/launch?placement=course_navigation',
'required_permissions': 'manage_calendar',
'selection_height': 500,
'selection_width': 500
}
]
}
}
],
"public_jwk": {
"kty": "RSA",
"alg": "RS256",
"e": "AQAB",
"kid": "8f796169-0ac4-48a3-a202-fa4f3d814fcd",
"n": "nZD7QWmIwj-3N_RZ1qJjX6CdibU87y2l02yMay4KunambalP9g0fU9yZLwLX9WYJINcXZDUf6QeZ-SSbblET-h8Q4OvfSQ7iuu0WqcvBGy8M0qoZ7I-NiChw8dyybMJHgpiP_AyxpCQnp3bQ6829kb3fopbb4cAkOilwVRBYPhRLboXma0cwcllJHPLvMp1oGa7Ad8osmmJhXhM9qdFFASg_OCQdPnYVzp8gOFeOGwlXfSFEgt5vgeU25E-ycUOREcnP7BnMUk7wpwYqlE537LWGOV5z_1Dqcqc9LmN-z4HmNV7b23QZW4_mzKIOY4IqjmnUGgLU9ycFj5YGDCts7Q",
"use": "sig"
'public_jwk': {
'kty': 'RSA',
'alg': 'RS256',
'e': 'AQAB',
'kid': '8f796169-0ac4-48a3-a202-fa4f3d814fcd',
'n': 'nZD7QWmIwj-3N_RZ1qJjX6CdibU87y2l02yMay4KunambalP9g0fU9yZLwLX9WYJINcXZDUf6QeZ-SSbblET-h8Q4OvfSQ7iuu0WqcvBGy8M0qoZ7I-NiChw8dyybMJHgpiP_AyxpCQnp3bQ6829kb3fopbb4cAkOilwVRBYPhRLboXma0cwcllJHPLvMp1oGa7Ad8osmmJhXhM9qdFFASg_OCQdPnYVzp8gOFeOGwlXfSFEgt5vgeU25E-ycUOREcnP7BnMUk7wpwYqlE537LWGOV5z_1Dqcqc9LmN-z4HmNV7b23QZW4_mzKIOY4IqjmnUGgLU9ycFj5YGDCts7Q',
'use': 'sig'
},
"custom_fields": {
"bar": "$Canvas.user.sisid"
'custom_fields': {
'bar': '$Canvas.user.sisid'
}
}

domain = self.request.get_host()
launch_url = '%s://%s/%s' % (
self.request.scheme, domain,
settings.LTI_TOOL_CONFIGURATION['launch_url'])

ctx = {
'domain': domain,
'launch_url': launch_url,
'title': settings.LTI_TOOL_CONFIGURATION['title'],
'description': settings.LTI_TOOL_CONFIGURATION['description'],
'embed_icon_url':
settings.LTI_TOOL_CONFIGURATION['embed_icon_url'],
'embed_tool_id': settings.LTI_TOOL_CONFIGURATION['embed_tool_id'],
}
return ctx
return JsonResponse(json_obj)


@method_decorator(xframe_options_exempt, name='dispatch')
Expand Down

0 comments on commit 5107c59

Please sign in to comment.