Skip to content

Conversation

xitij2000
Copy link

@xitij2000 xitij2000 commented Aug 29, 2025

Description

Currently the LTI provider implementation auto-creates a random user when logging in, however, the LTI launch can include relevant user details such as their email, full name and even a username. This change makes the LTI code use the provided details if the "Use lti pii" setting is set in the Django admin.

Cherry Pick openedx#37307

Copy link

sentry-io bot commented Aug 29, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: lms/djangoapps/lti_provider/users.py

Function Unhandled Issue
authenticate_lti_user AttributeError: 'NoneType' object has no attribute 'lower' /lti_provider/courses/{course_id}[/+]+{var}[/]+)/{usage...
Event Count: 12

Did you find this useful? React with a 👍 or 👎

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @xitij2000, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the LTI provider's capability to manage user accounts by enabling the use of personal information transmitted via LTI launches. Instead of defaulting to anonymous user creation, the system can now be configured to automatically populate user profiles with details like email and full name, streamlining the user onboarding process and providing a more complete user experience for LTI-integrated platforms.

Highlights

  • New LTI PII Setting: Introduced a new use_lti_pii boolean field in the LtiConsumer model, allowing administrators to configure whether personal identifiable information (PII) from LTI launches should be used to create user accounts.
  • Enhanced User Profile Population: The LTI provider can now utilize LTI launch parameters such as email (lis_person_contact_email_primary), full name (lis_person_name_full), given name (lis_person_name_given), and family name (lis_person_name_family) to populate user profiles (email, full name, and username) during account creation or linking.
  • Improved User Creation Logic: Refactored the create_lti_user function to accept a profile dictionary, enabling more flexible and data-driven user creation. This includes handling cases where usernames might be missing or duplicate, ensuring unique usernames are generated.
  • Test Coverage Expansion: Added extensive new test cases using ddt (data-driven testing) to cover various scenarios for user creation with LTI PII, ensuring the robustness of the new functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature to populate user profiles using data from LTI launches, controlled by a new use_lti_pii setting. The implementation is well-structured, with logic correctly refactored into helper functions and existing functions updated to handle the new profile data. The changes are robust, covering scenarios like pre-existing users and duplicate usernames. The accompanying tests are comprehensive and cover the new functionality well. I have one minor suggestion to clean up a duplicated test case.

@xitij2000 xitij2000 force-pushed the kshitij/lti-auth-auto-create-account-teak branch 2 times, most recently from 3d8e210 to a74614d Compare September 1, 2025 05:33
arslanashraf7 and others added 2 commits September 2, 2025 12:26
* feat: add canvas integration support

(cherry picked from commit fdb818a)
When dealing with subsections that have a lot of units, show a dropdown for
unit selection to simplify navigation.

(cherry picked from commit aaca11f)
@pdpinch
Copy link
Member

pdpinch commented Sep 3, 2025

@xitij2000 can you resolve the conflicts with this PR?

Currently the LTI provider implementation auto-creates a random user when
logging in, however, the LTI launch can include relevant user details such as
their email, full name and even a username. This change makes the LTI code
use the provided details if the "Use lti pii" setting is set in the Django
admin.

(cherry picked from commit 0bed7d7)
@xitij2000 xitij2000 force-pushed the kshitij/lti-auth-auto-create-account-teak branch from a74614d to dc60e55 Compare September 3, 2025 07:12
@xitij2000
Copy link
Author

@xitij2000 can you resolve the conflicts with this PR?

Done

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