Dansubak/202510 wip lti with jupyterhub #2627
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (What does it do?)
This is a proof of concept for setting up Learn as an LTI platform for use with Jupyterhub as a tool provider. The primary feature we're interested in using is the ability to pass a user's role and some supporting course metadata from Learn to Jupyterhub, which LTI supports via custom claims in their tool launch request.
This was tested against a local checkout of Jupyterhub's Dockerspawner simple example, using the following configuration:
How can this be tested?
This assumes you can access Learn Django APIs at http://api.open.odl.local:8065/ and that you are using Docker Desktop (as we use
host.docker.internalfor routing one portion of the negotiation)Set up Jupyterhub
examples/simple.jupyterhub-ltiauthenticatortorequirements.txtjupyterhub_config.pywith the configuration above.docker network create jupyterhub && docker build -t hub . && docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock --net jupyterhub --name jupyterhub -p8000:8000 hubSet up Learn
platform_id_rsaandplatform_id_rsa.pubrespectivelydocker-compose upRun the actual test
quay.io/jupyter/pytorch-notebook. The course can be anything you like.import torchsuccessfully)User is stafforUser is a learnerdepending on whether or not you've logged in as a superuser to Learn.Additional Context
This PR uses the openedx xblock-lti-consumer package - specifically it leverages the use-agnostic 1.3 consumer. Unfortunately this means that we pull in a lot of extra unused functionality, but it is sufficiently flexible that we can plug it in anywhere. The only other packaged platform implementation for LTI 1.3 that I found was https://pypi.org/project/lti1p3platform/ but since I couldn't find a corresponding repository for it, I opted for this one.
This proof of concept exists to demonstrate one possibility for identifying users vs authors within our jupyter notebooks. For more information in how this may be used, see this writeup for a discussion on the potential approaches.