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

Registered / unregistered platform #86

Closed kimon-satan closed 3 years ago

kimon-satan commented 3 years ago

Apologies for posting here as I fear this is probably my error rather than a genuine bug. I am attempting to register the demo-server running on a remote server with a moodle instance on a separate remote. I've uncommented the "register platform" code and provided appropriate urls and variables from the moodle configuration.

I get the following on startup

provider:main Platform already registered +39ms

but the following on attempting to launch the tool

provider:main Receiving request at path: /login +16s provider:main Receiving a login request from: http://doc18.doc.gold.ac.uk/moodle +1ms provider:main Unregistered platform attempting connection: http://doc18.doc.gold.ac.uk/moodle +5ms

The client receives {"status":400,"error":"Bad Request","details":{"message":"UNREGISTERED_PLATFORM"}}

Here is my moodle config

image

Here is my register platform call:

` /**

Do you have any idea of where I'm going wrong ?

Cvmcosta commented 3 years ago

Hello @kimon-satan!

Your platform URL seems to be incorrect, I imagine that http://doc18.odc.gold.ac.uk/moodle should be http://doc18.doc.gold.ac.uk/moodle, right?

Also, on Moodle you can use Public Keyset instead of RSA Key. Change the "Public Key Type" and use the /keys endpoint of Ltijs: <your_lti_server>/keys

It is preferred over RSA Keys.

kimon-satan commented 3 years ago

Thanks for the quick response! Whoops, how embarrassing :)

I've fixed that now and I'm one stage forward but still not quite getting it . Sorry

I now get a 401 error on launch

{"status":401,"error":"Unauthorized","details":{"description":"No Ltik or ID Token found.","message":"NO_LTIK_OR_IDTOKEN_FOUND","bodyReceived":{}}}

This is the log from the server

provider:main Platform already registered +60ms provider:main Receiving request at path: /login +13s provider:main Receiving a login request from: http://doc18.doc.gold.ac.uk/moodle +1ms provider:main Redirecting to platform authentication endpoint +7ms provider:main Target Link URI: http://doc.gold.ac.uk/www/495 +0ms provider:main Login request: +3ms 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: '7NMoBFDXOI7zqk0', provider:main redirect_uri: 'http://doc.gold.ac.uk/www/495', provider:main login_hint: '2', provider:main nonce: 'ppphoz7godehxthl05u9xw5dv', provider:main prompt: 'none', provider:main state: '950961946c787f889d2e9c1c6fd02ac7a62e13357e026dd5b6', provider:main lti_message_hint: '4', provider:main lti_deployment_id: '2' provider:main } +0ms provider:main Receiving request at path: / +153ms provider:main Path does not match reserved endpoints +1ms provider:main Cookies received: +0ms provider:main [Object: null prototype] { provider:main state950961946c787f889d2e9c1c6fd02ac7a62e13357e026dd5b6: 'http://doc18.doc.gold.ac.uk/moodle' provider:main } +0ms provider:main No ltik found +1ms provider:main Request body: {} +0ms provider:main Passing request to invalid token handler +0ms

I've tried setting sameSite to 'None' and also adding extra route to the redirect URI in moodle but to no avail. What am I still getting wrong here ?

Thanks for your help so far.

Cvmcosta commented 3 years ago

Hello! i can't see anything wrong with your setup, what is weird is that Moodle did not return any error message. Any error in the LTI protocol would be displayed in the bodyReceived section of the error object. I imagine this might be something related to the lack of https, but i can't be sure.

Would it be possible for me to have access even as a student to this test Moodle, so i can analyze the network and see if i can spot the issue?

kimon-satan commented 3 years ago

Okay I've made an account with site admin access for you but is there a way to DM you to share credentials ? I'll also try tomorrow to sort out certs for both sites so I can try with https

Cvmcosta commented 3 years ago

You can send the credentials to cvmcosta@gmail.com. Thanks!

kimon-satan commented 3 years ago

I'm not sure how but I solved it now.

My suspicion was two basic things wrong

  1. a forward slash after the server URL in moodle ? (perhaps)
  2. you need to be enrolled on the moodle course (site admins have access to all courses so this is confusing)

I can't see anything else that I changed. In any case I have it working locally and remotely. Thanks

Cvmcosta commented 3 years ago

Hello @kimon-satan! Sorry i wasn't able to test the issue yesterday. I am happy you figured it out!

The issue was probably the forward slash, since Moodle lets you launch to applications you're not enrolled in if you are the admin.

mayank-kabra2001 commented 1 year ago

Hi, I have written everything correct!! image image I am still getting unregistered platform error. Can someone help me out ?

Cvmcosta commented 1 year ago

Hello @mayank-kabra2001 Can you please check in the network tab the login request and its payload? We are looking specifically for the iss and client_id claims. These should match the url and clientId fields in your registration. If they match, i'd check the database to make sure the registration is actually completing correctly.