CELTIC Python Bindings
This module contains a thin wrapper around the CELTIC service which allows for cross-platform LTI validation.
Dependencies
Tests
tox is used as a test runner for this library. It is configured to run tests for py27, py35 and py36.
pip install tox tox
Usage
from celtic_lib import get_lti_validator, LTIValidatorException
LTI_LISTEN_LOCATION = "https://localhost:8000/lti"
def handle_request(request):
"""
request contains some LTI payload you just received in your application
"""
app_key = "some_long_unique_string_unique_to_this_application"
celtic_service_uri = "https://location_of_celtic_service.net/"
lti_validator = get_lti_validator(celtic_service_uri, app_key)
http_method = request.method # Will be "POST", since we are only listening on the POST endpoint
try:
status, result = lti_validator.validate_request(LTI_LISTEN_LOCATION, http_method, request.POST)
return print("Request is valid and can be trusted")
except LTIValidatorException as e:
return print("Request failed:", e.message, "|", e.status_code)
# router is an imaginary application router.
# For purposes of this is makes the handle_lti_request function handle all POST requests which are directed at LTI_LISTEN_LOCATION
router.on(LTI_LISTEN_LOCATION, "POST", handle_lti_request)
Architecture
This module is fairly straightforward, it forwards any LTI request to a secure endpoint which contains a record of the oauth_consumer_key and the secret_key. This remote endpoint then validates the request, and returns a simple response indicating its validity.
DataRequester This class exposes a post method which takes the CELTIC service endpoint, and the POST data to send it. It returns the CELTIC response wrapped in the following interface:
* status_code<int> * json()<dict>
The primary reason of this class is to allow users to swap out the default DataRequester for their own to provide better control over the application
LTIValidator A class which handles the plumbing of the LTI validation. It is given a CELTIC service URI, an app_key, and a DataRequester instance. The user then only needs to call the validate_request method with a forwarded LTI payload to determine the validity of it.
LTIValidatorException An exception thrown when the server returns a not-good error code about the LTI response. The exception exposes the following data:
* message<string> - The error message the CELTIC server responded with * status_code<int> - The HTTP status code the CELTIC server responded with * errors<dict> - The response body the CELTIC service responded with
Developing
To make improvements to this package, the following is required:
* A python environment
* [pandoc](https://pandoc.org/installing.html) is used to convert this README.md into `reStructuredText`
1. First: pip install pypandoc
2. Second: Download installer from pandoc website
Metadata
Release files for celtic_lib 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| celtic_lib-0.0.7.tar.gz | 4.2 kB | Without provenance | Details for celtic_lib-0.0.7.tar.gz |
Release files / celtic_lib-0.0.7.tar.gz
| Download URL | celtic_lib-0.0.7.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53c4dd5c8399692411e14ec008a1b8d1e6cf8d391e1701a2dabd5d909706b1db
|
|
BLAKE2b-256 checksum How to use checksums |
cee80f53fec175803c97cc6018fe6a6cc1e5d9127aae65cea53e6fe7a92c7d64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for celtic_lib 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.