This repository documents a docker sandbox environment to test integration between the Moodle LMS and JupyterHub. This repository was extensively used to test LTI (v1.1) authentication from Moodle to JupyterHub using the LTI Authenticator library. This repository was adapted from the existing jupyterhub-deploy-docker
project, which is distributed under the BSD 3-Clause License. In addition, docker images for the Moodle LMS were pulled from Bitnami.
Disclaimer: The source code in this repository is meant solely for testing purposes and is not designed for production use.
Since this repository operates on the level of docker containers, working installations of docker
and docker-compose
are required. This repository was tested against versions 20.10.16
and 2.5.1
respectively.
In the next steps, we assume that the user executing commands is part of the docker
group and therefore can execute docker
commands without superuser privileges (or sudo
). If this is not the case for your environment, then the commands below must be executed with superuser privileges (or sudo
).
Build
To build relevant docker images, networks, volumes and generate secret data, simply execute:
$ make build
The following will be generated and dumped as files in jupyterhub/secrets/
:
- A randomly generated
postgres
password for thejupyterhub
database - A randomly generated LTI client key and shared secret
- An admins file for granting administrative rights to the
admin
user
Up
To create and start relevant containers, simply execute:
$ make up
This will detach as a background process and it can take several minutes for the installation of Moodle to finish. Open http://localhost
in your browser to access the Moodle UI.
Log
To view logs from launched docker containers, simply execute:
$ make log
Down
To stop and remove previously created docker containers and networks, simply execute:
$ make down
Restart
To restart all containers, simply execute:
$ make restart
Note: This will stop/remove all containers and rebuild images from scratch. This is useful for testing changes in configurations.
Clean
To stop and remove previously created docker containers, networks, volumes and secret data, simply execute:
$ make clean
Follow the instructions below to test LTI authentication from Moodle to JupyterHub:
-
Execute the following to launch all docker services:
$ make up
Note: The installation of Moodle can take several minutes to complete. Execute
make log
to view live installation logs. -
Open
http://localhost
in your browser and log in withadmin
as the username andpassword
as the password. -
After logging in, select the following sequence of options:
Site home > ⚙️ > Restore > Choose a file > Upload a file > Navigate filesystem and select
moodle-courses/lti_template.mbz
> Upload this file > Restore -
You will then be directed to a set of pages to refine how the restoration is done. On page 2. Destination, select the option to continue via Restore as a new course. Update preferences or accept defaults on pages 3-5. If all goes well, select Perform restore on page 5.
-
Navigate to Site home and select the Test course.
-
Select Turn editing on and select Edit > Edit settings options corresponding to the green puzzle-shaped icon with the JupyterHub tag.
-
Then select the ⚙️ button in the Preconfigured tool field.
-
Copy the LTI client key from
jupyterhub/secrets/lti.key
and paste it in the Consumer key field. Copy the LTI shared secret fromjupyterhub/secrets/lti.secret
and paste it in the Shared secret field. -
Select Save changes and then return to the Test course.
-
Select the green puzzle-shaped icon with the JupyterHub tag and you will be authenticated to
jupyterhub
as theadmin
user.