Ensure correct LTI version of lti_user_id is used on launch #7335
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.
Proposed Changes
LTI launch from canvas is using LTI v1.1 for it's lti_user_id attribute. We need to use LTI v1.3 one as Roster sync uses this one, which is found under the subject attribute, "sub". LTI v1.1 and LTI v1.3 both have different values for lti_user_id.
If an instructor logs in from canvas and then does an Roster sync, other users who then launches from Canvas will get the following log error:
Couldn't find LtiUser with [WHERE "lti_users"."user_id" = $1 AND "lti_users"."lti_client_id" = $2 AND "lti_users"."lti_user_id" = $3]
On production mode, they will see a 404 error on the browser but we will see the same error in the logs.
The reason this errors comes about is that when during the Launch, the following code is run in lti_deployments_controller.rb:
LtiUser.find_or_create_by(user: @real_user, lti_client: lti_client,
lti_user_id: lti_data[:lti_user_id])
It will first try to find this user, which they would not because of the different LTI versions, it would then try to create the user, but the DB would not allow it because of the unique index that requires User_id and lti_client_id combined has to be unique. So it would then raise the above error.
To test this locally:
...
Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)
Type of Change
(Write an
X
or a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]
into a[x]
in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)