This project aims to provide a dead simple way to integrate LTI Authentication into your Django powered app. Try it now, and get rid of the complicated configuration of LTI.
Usage
Set up the app as an LTI tool on Moodle. You need to specify the following:
Secure Tool URL:
Consumer key and Shared secret:
Import the views module in your root urls.py
# this is main urls.py for the project from django.conf.urls import url, include urlpatterns += [ url(r'^lti/', include('django_lti_auth.urls')), ... ]In settings.py, add the LTI related configuration.
PYLTI_CONFIG = { "consumers": { "<djangoConsumerKey>": { "secret": "<djangoSecret>" } }, "method_hooks":{ "valid_lti_request":"<Specify method to call after validation of a valid LTI payload>", "invalid_lti_request":"<Specify method to call after validation of an invalid LTI payload>" }, "next_url":"<Default home page>" }You also need to add the following settings into your settings.py file.
X_FRAME_OPTIONS = 'ALLOW-FROM https://moodle.telt.unsw.edu.au/' SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_SSL_REDIRECT = False SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = TrueAdd ‘django_lti_auth’ to INSTALLED_APPS
INSTALLED_APPS = [ '...', 'django_lti_auth', ]
Explanation
valid_lti_request - The module calls the method you specify here after validating the LTI payload if the payload is valid. The method passes the LTI payload values extracted into a python dictionary as an argument to this method. You can use this payload to bind the user variables to the session.
def valid_lti_request(user_payload, request): ... request.session['userid'] = user_payload['user_id'] request.session['roles'] = user_payload['roles'] request.session['context_id'] = user_payload['context_id'] ...You can return a URL value in case you want to redirect the LTI authenticated user to a new URL after the LTI Authentication.
def valid_lti_request(user_payload, request): ... url = reverse('<intented URL string>', kwargs={'context': user_payload['context_id'], 'userid':user_payload['user_id']}) return urlinvalid_lti_request - This method is called after validation when the LTI payload is invalid. You can use this method to redirect the user back to the login page (or an access denied page).
Installation
To install the package run the following command:
pip install django-lti-auth
Requirements
PyLTI==0.5.1
Licence
MIT license
Metadata
Release files for django-lti-auth 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_lti_auth-1.0.0.tar.gz | 31.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_lti_auth-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 36.6 kB
Release files / django_lti_auth-1.0.0.tar.gz
| Download URL | django_lti_auth-1.0.0.tar.gz |
|---|---|
| Size | 31.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30bd74f233f96b2e2e6ecaca43eecf7c0e1a4e4e69f741c92a80dc68b0c1743a
|
|
BLAKE2b-256 checksum How to use checksums |
5da48716cc18e4905cc89fe7b25525a68e1e9c48ab192945f209c3513ae01493
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
|
Release files / django_lti_auth-1.0.0-py2.py3-none-any.whl
| Download URL | django_lti_auth-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5518977c3f6db1552ff5214f4ca8c1eb2060438fbf322bc7e9d0beafa254b860
|
|
BLAKE2b-256 checksum How to use checksums |
fc0d4ffadc998e704edfb2e64dd9a8fc2f7ce74a1003264b9df3139d07245055
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
|