LTI tool support for Django
Project description
django-lti
A Django reusable app providing support for LTI Advantage.
Installation
Install using pip.
pip install django-lti
Setup
Start by adding lti_tool
to your project's INSTALLED_APPS
.
INSTALLED_APPS = [
...
"lti_tool",
]
Then, add lti_tool.middleware.LtiLaunchMiddleware
to the MIDDLEWARE
setting.
It's important to list the LtiLaunchMiddleware
after SessionMiddleware
.
MIDDLEWARE = [
...
'django.contrib.sessions.middleware.SessionMiddleware',
'lti_tool.middleware.LtiLaunchMiddleware',
]
Finally, run migrations to initialize the needed database tables.
python manage.py migrate lti_tool
Usage
Adding JWKS and OIDC initiation URLs
To allow LTI platforms to retrieve a JWKS and initiate a launch, add paths for
lti_tool.views.jwks
and lti_tool.views.OIDCLoginInitView
to urls.py
...
from lti_tool.views import jwks, OIDCLoginInitView
urlpatterns = [
path(".well-known/jwks.json", jwks, name="jwks"),
path("init/<uuid:registration_uuid>/", OIDCLoginInitView.as_view(), name="init"),
]
Generating and rotating keys
Keys for the JWKS can be generated using the rotate_keys
management command.
python manage.py rotate_keys
Registering an LTI platform
An LTI platform can be registered through the Django admin, or using a custom interface.
Handling an LTI launch
To handle the LTI launch, inherit from LtiLaunchBaseView
and implement the handler
methods for the types of LTI message types that the application supports.
class ApplicationLaunchView(LtiLaunchBaseView):
def handle_resource_launch(self, request, lti_launch):
... # Required. Typically redirects the users to the appropriate page.
def handle_deep_linking_launch(self, request, lti_launch):
... # Optional.
def handle_submission_review_launch(self, request, lti_launch):
... # Optional.
def handle_data_privacy_launch(self, request, lti_launch):
... # Optional.
Each handler method receives the request, as well as a LtiLaunch
object.
When a session is initiated by an LTI launch, data about the launch is available from
the request at request.lti_launch
as an LtiLaunch
object. During a non-LTI session
request.lti_launch
will refer to an AbsentLtiLaunch
object.
It is possible to distinguish between LtiLaunch
and AbsentLtiLaunch
objects using
the .is_present
and .is_absent
properties.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_lti-0.7.0.tar.gz
.
File metadata
- Download URL: django_lti-0.7.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfd84a1d496ac876b3a838cdc550054684360ae7a99ee99739f62db8fe935abc |
|
MD5 | 190e36c05deb1d136c3fdf070df1eecd |
|
BLAKE2b-256 | de6cbece3f36d2e1845d2517235559a28ff3f47496a6cd1086c74e155002f71d |
File details
Details for the file django_lti-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: django_lti-0.7.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e587f96cba566c4b1ce8b0451d25b911d5d0c67121282b4fb2edb02577598cfa |
|
MD5 | 89e373ad508add0e77448308a14294fc |
|
BLAKE2b-256 | bc0975f0e27c1a5c6b44c9574ad7b1a008bca81d2e80fd0a4229be0bed588681 |