Cvmcosta / ltijs

Turn your application into a fully integratable LTI 1.3 tool provider.
https://cvmcosta.github.io/ltijs/
Apache License 2.0
299 stars 67 forks source link

Canvas locally-hosted internal server error when sending request to authorize_redirect endpoint #161

Open pepeL95 opened 2 years ago

pepeL95 commented 2 years ago

Hello,

Describe the bug When attempting to access the Canvas authorize_redirect endpoint, it throws an internal server error (error code 500). When I check the Canvas error log it says "undefined method `sign' for nil:NilClass". Any help would be greatly appreciated.

Registration Code await lti.registerPlatform({ url: 'https://canvas.instructure.com', name: 'Canvas Instructure', clientId: '10000000000005', authenticationEndpoint: 'http://192.168.1.43/api/lti/authorize_redirect', accesstokenEndpoint: 'http://192.168.1.43/login/oauth2/token', authConfig: { method: 'JWK_SET', key: 'http://192.168.1.43/api/lti/security/jwks' } })

Debug console logs provider:main Platform already registered +47ms provider:main Receiving request at path: /login +9s provider:main Receiving a login request from: https://canvas.instructure.com, clientId: 10000000000005 +1ms provider:main Redirecting to platform authentication endpoint +6ms provider:main Target Link URI: http://localhost:3000 +0ms provider:main Login request: +2ms provider:main { provider:main response_type: 'id_token', provider:main response_mode: 'form_post', provider:main id_token_signed_response_alg: 'RS256', provider:main scope: 'openid', provider:main client_id: '10000000000005', provider:main redirect_uri: 'http://localhost:3000', provider:main login_hint: '33f5627d790a427db3d213600ad0bddc85411a1a', provider:main nonce: 'lcouezf8unuh6tib8rbd43gbz', provider:main prompt: 'none', provider:main state: '008171e660418d3f2b72eec60cb455f854e16378d2321f2b9e', provider:main lti_message_hint: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJpZmllciI6IjMxZDhkOGE4ZDQ3ODcwOWFlMDNhMDk2ODQzZjU2ZTI4MTk1MjJlMmYzYjg3YWQzYjNjYWIyMWM0ZjEwZTM2NjMwYzYzMjE0YTMxN2QwZDFiYjVhMjZiZDJiZjE5NDJjOWZlOWY2Y2MwM2E0YjVhNzBhNzU1OTUwYTc4ZGM0ZTA3IiwiY2FudmFzX2RvbWFpbiI6IjE5Mi4xNjguMS40MyIsImNvbnRleHRfdHlwZSI6IkFjY291bnQiLCJjb250ZXh0X2lkIjoxMDAwMDAwMDAwMDAwMiwiY2FudmFzX2xvY2FsZSI6ImVuIiwiZXhwIjoxNjYyMjM0NDAwfQ._gxbB92MEb_nt5anHjdy39C3PSg4QS3fG4smjiVMO3M' provider:main }

Ltijs version

NodeJS version

Platform used

dmolin commented 2 years ago

@pepeL95 I'm having issues with Canvas too (even if mine are in the Deep linking flow). Can I ask you how/where did you access the Canvas error log?

pepeL95 commented 2 years ago

Yea, just type in the browser http://your-canvas-host/error_reports/your-error-id

For example, in my case I typed http://192.168.1.43/error_reports/1 @dmolin

Cvmcosta commented 2 years ago

Hello! How are you deploying your Canvas? Self hosted canvas is notoriously problematic with LTI. I'd suggest trying to connect to another public test LTI tool and checking if the error persists (something likt saLTIre). The bitnami version of Canvas also doesn't work with LTI out of the box as far as i know.

Cvmcosta commented 2 years ago

I used this tutorial to get Canvas up and running with ngrok and get LTI working.

Canvas On Docker With ngrok

1. Pull Canvas Git Repo

 git@github.com:instructure/canvas-lms.git
 # (optional) git checkout stable

2. Install Prereqs

brew install mutagen-io/mutagen/mutagen
brew install mutagen-io/mutagen/mutagen-compose

3. Run

./script/docker_dev_setup.sh

It will ask for an admin username and password and other simple setup questions.

4. Run The Container(s)

mutagen-compose up -d

5. Run ngrok

ngrok http --host-header=rewrite canvas.docker:80

ngrok will give you a public URL to user during this session. After the ngrok tunnel is closed, there is no guarantee that you will get the same url in a new session.

Stopping the containers
mutagen-compose down

After stopping, you can rerun starting at step 4 as long as your system configuration doesn't change.

dmolin commented 2 years ago

Hello! How are you deploying your Canvas? Self hosted canvas is notoriously problematic with LTI. I'd suggest trying to connect to another public test LTI tool and checking if the error persists (something likt saLTIre). The bitnami version of Canvas also doesn't work with LTI out of the box as far as i know.

Bitnami Canvas actually does work. I use it with no issues; The only problem there was that the Bitnami VM doesn't ship with a correct ntp configuration (that is, no ntp is configured at all)) so the local VM time is always wrong and that impact on the LTI messaging; though, it's an easy fix and after that the VM works without issues.

Though, the issue I'm having (see the issue I opened on deep linking) seems to be Canvas-specific and I don't think has anything to do with Canvas running in a VM.

pepeL95 commented 2 years ago

@dmolin May I ask how did you fix the ntp configurations?

pepeL95 commented 2 years ago

@Cvmcosta Thank you for your response. I will give that a try some time this week and will let you know how that goes

dmolin commented 2 years ago

@dmolin May I ask how did you fix the ntp configurations?

Here are the step I followed (I'm pulling that from memory but that should be roughly correct):

Fixing Bitnami's VM