Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure correct LTI version of lti_user_id is used on launch #7335

Conversation

donny-wong
Copy link
Contributor

@donny-wong donny-wong commented Dec 2, 2024

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:

  1. Empty out lti_users table in DB
  2. Launch from Canvas to MarkUs as an instructor
  3. Do Roster sync
  4. On Canvas, act as another user in that course and launch MarkUs
  5. You will now be able to log in without the above error

...

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.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) x
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

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:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@donny-wong donny-wong changed the title Ensure correct lti user id on launch Ensure correct LTI version of lti_user_id is used on launch Dec 2, 2024
@coveralls
Copy link
Collaborator

coveralls commented Dec 2, 2024

Pull Request Test Coverage Report for Build 12112271970

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.758%

Totals Coverage Status
Change from base Build 12107303502: 0.0%
Covered Lines: 41173
Relevant Lines: 44196

💛 - Coveralls

@donny-wong donny-wong added this to the v2.6.1 milestone Dec 3, 2024
@david-yz-liu david-yz-liu merged commit 00c41cf into MarkUsProject:master Dec 3, 2024
6 checks passed
donny-wong added a commit to donny-wong/Markus that referenced this pull request Dec 6, 2024
…oject#7335)

---------

Co-authored-by: Donny Wong <donnywong@cs.toronto.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants