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

Login with the email address (alternate login ID) renames Moodle user #2389

Closed
lukaslangkissC02 opened this issue Oct 13, 2023 · 3 comments · Fixed by #2459 or #2460
Closed

Login with the email address (alternate login ID) renames Moodle user #2389

lukaslangkissC02 opened this issue Oct 13, 2023 · 3 comments · Fixed by #2459 or #2460
Assignees
Labels
Feature - SSO Feature - user sync Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - auth_oidc Plugin - local_o365 Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release. Triaging status - triaged A ticket has been created accordingly in the maintainers' ticket system.
Milestone

Comments

@lukaslangkissC02
Copy link

We have enabled the Microsoft Entra-ID feature to allow users to sign-in with an email address. (https://learn.microsoft.com/en-us/azure/active-directory/authentication/howto-authentication-use-email-signin#enable-user-sign-in-with-an-email-address)

If we enable the plugin feature "Support Microsoft account UPN change", Moodle users will be renamed when they log in with one of their email addresses, even though the UPN has not changed.

Example
UPN: 12345@domain.com
Alternate email address: firstname.lastname@domain.com

The Moodle user is created by the task "Sync users with Azure AD" (\local_o365\task\usersync) with the username 12345@domain.com and matched to his Microsoft 365 user (OpenID Connect). If the user logs in with firstname.lastname@domain.com, then the Moodle user will be renamed. Therefore, the plugin does not correctly detect the change of UPN.

@weilai-irl weilai-irl self-assigned this Jan 18, 2024
@weilai-irl weilai-irl added Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Triaging status - triaged A ticket has been created accordingly in the maintainers' ticket system. Feature - user sync Plugin - auth_oidc Plugin - local_o365 Feature - SSO labels Jan 18, 2024
@weilai-irl
Copy link
Collaborator

Hi @lukaslangkissC02

Thank you for reporting the issue.

First of all, I confirm I can recreate the issue in my test.

I did a bit of investigation to see if this is something that is technically feasible to be fixed, and unfortunately it's infeasible. This happens when using "Microsoft Identity Platform (v2.0)" connection method with the "Email as an alternate login ID" Azure configuration enabled. When using v2.0 connection method, the auth_oidc plugin uses the preferred_username claim in token to determine the username of a Microsoft user. In my test, when the "Email as an alternate login ID" configuration is enabled and the Microsoft user logs in using email rather than username, this claim contains the email address. I checked other claims as well and none contains the actual username of the Microsoft account. I also checked if there's any claim that can tell whether the login is using email or username, and I didn't find any.

By contrast, when using "Azure AD (v1.0)" connection method, the auth_oidc plugin uses the upn claim to as the preferred source of Microsoft account username, and it always contains the actual username of the account, regardless whether the user logs in using username or email address.

So to conclude, there is nothing that can be done in the auth_oidc plugin to prevent auth_oidc renaming Moodle user if:

  1. "Microsoft Identity Platform (v2.0)" is configured as connection method, and
  2. "Email as an alternate login ID" configuration in Azure is turned on, and
  3. "Support Microsoft account UPN change" configuration in Moodle is enabled, and
  4. The Microsoft user logs in using email address rather than username.

The best I can do is to include a note to the documentation of the plugins in the section about "Support Microsoft account UPN change" configuration to highlight the potential risk.

If you have other ideas, please let me know. Otherwise the issue will be closed in the next few days.

Regards,
Lai

@weilai-irl
Copy link
Collaborator

Hi again @lukaslangkissC02

Slight change of plan - the documentation change will be made within the local_o365 plugin, in the description of the "Support Microsoft account UPN change" settings. This will be included in the next release.

Regards,
Lai

@weilai-irl
Copy link
Collaborator

Hi all,

The proposed changes in configuration settings have been included in the releases from today.

Thank you very much for reporting the issue.

Regards,
Lai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature - SSO Feature - user sync Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - auth_oidc Plugin - local_o365 Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release. Triaging status - triaged A ticket has been created accordingly in the maintainers' ticket system.
Projects
None yet
2 participants