Skip to content

Dev: Configuration for LTI 1.3 Development

Code Hugger (Matthew Jones) edited this page Aug 25, 2022 · 8 revisions

Install and Configure MyLA

To complete the steps in the following sections, MyLA must be configured according to the project's README.md document. It needs to be installed on a server that is accessible by the LMS. The next section explains the installation of a simple server for development purposes.

Install Server

LTI 1.3 requires the client, an LMS like Canvas, to contact the tool server, which hosts MyLA. That means when MyLA runs on a computer in a development environment, it needs to be available online in a way that the LMS can contact it via HTTPS. There are a number of ways that can be accomplished, but the easiest is to install ngrok and run it. It will dynamically create a hostname for the application and give a URL for it that can be accessed anywhere online. Requests to that URL will be forwarded to the local computer through a network tunnel.

  • Follow the installation instructions on ngrok's download page.

    • Alternate installation methods (may not be officially supported by ngrok.com)
      • Using Homebrew (macOS or Linux)

        brew cask install ngrok
      • Using npm

        npm install ngrok
  • Add .ngrok.io to the ALLOWED_HOSTS array of MyLA's env.json configuration file. For example:

    "ALLOWED_HOSTS": [
            "127.0.0.1",
            "localhost",
            ".ngrok.io"
        ],
  • Start MyLA on the local computer using Docker:

    docker-compose up

    It runs on port 5001 by default.

  • Start a ngrok forwarding tunnel:

    ngrok http 5001

    💡 – ngrok's "http" tunnel automatically handles both HTTP and HTTPS.

    While ngrok runs, it offers some helpful troubleshooting and debugging interfaces:

    • https://dashboard.ngrok.com/status/tunnels – Shows the active forwarding tunnels for the local computer. This requires free registration with ngrok.com. Additional features become available with a paid registration.

    • http://127.0.0.1:4040 – View the incoming requests and inspect them.

    • To programmatically get the URL of the first running tunnel:

      # if jq is installed
      curl -s http://127.0.0.1:4040/api/tunnels | \
        jq -r '.tunnels[0].public_url'
      
      # without jq
      curl -s http://127.0.0.1:4040/api/tunnels | \
        sed 's/^.*"public_url":"\([^"]*\)".*$/\1/'

Keys and Configuration

For development purposes, procedures for the generation of keys, configuration of MyLA, and configuration of LTI keys in the LMS (Canvas) are the same as those for production deployment. Therefore, please see the Generate Keys, Configure Security Settings, and Configure LTI Settings sections of the document "Deploy: Configuration for LTI 1.3 Deployment".

⚠️ – The hostnamemyla.example.edu appears several times in the configuration examples of the deployment documentation. It must be replaced with the hostname of the computer on which MyLA is being tested. If you are using ngrok as a development server, as explained in the previous section, the hostname will be similar to EXAMPLE_NGROK_ID.ngrok.io , where EXAMPLE_NGROK_ID is typically a twelve-digit hexadecimal number, like 1337deadbeef.

Testing

After launching the tool from course navigation, if the course doesn't exist in MyLA's DB, the UI may display an image with the message "Course Data Being Processed; Try Back in 24 Hours". Make yourself an admin by going to django_auth table and change the is_superuser column value to 1. Run the batch job, then course data will be pulled in. After that, when the LTI launches you should see courses view page. Then if you use the "Act as User" feature in that course in Canvas, click the link in the Navigation, then you should acess MyLA as that user.

When developing locally with ngrok and webpack watch mode, the initial launch may take a long time since the various main-*.js files are not compressed in watch mode. This shouldn't be problem when running in production mode.

Enabling/Disabling the standard backend

The env.json setting ENABLE_BACKEND_LOGIN is automatically set to False if LTI is enabled. If this setting is set to True, the standard internal login and logout will work. This should only be enabled for testing.

pylti1.3 module

MyLA uses a third party module that implements LTI 1.3 workflows and validation. See the pylti1.3 GitHub repo for additional documentation.