Fix OIDC login for manually matched users with mismatching Entra username - #3363
Open
Lai Wei (weilai-irl) wants to merge 1 commit into
Open
Fix OIDC login for manually matched users with mismatching Entra username#3363Lai Wei (weilai-irl) wants to merge 1 commit into
Lai Wei (weilai-irl) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Improves OIDC login handling for users who were manually matched via Entra UPN when their Moodle username differs (e.g., Moodle username is only the UPN prefix). The change aims to ensure handlelogin() binds the session/token to the matched Moodle username and to reduce case-mismatch problems for Entra UPN lookups.
Changes:
- Normalize manual-match Entra UPN input to lowercase when saving new matches.
- Normalize Entra UPN input when searching for manual matches during OIDC login, and bind to the matched Moodle user’s actual username.
- Add a regression PHPUnit test covering the manually-matched user login flow.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
local/o365/classes/page/acp.php |
Lowercases manually-entered Entra UPN during manual match creation. |
auth/oidc/classes/loginflow/authcode.php |
Normalizes UPN before matching and binds login to the matched Moodle username. |
auth/oidc/tests/loginflow/authcode_test.php |
Adds regression coverage for first-login completion for manually matched users with differing Moodle username. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…name Manually matched users are keyed by Entra UPN, which often differs from the Moodle username. handlelogin() found the matched user but then discarded it, continuing with the UPN as the username and failing with "User not found in Moodle." Now it binds to the matched user's actual username instead. Also normalizes entraidupn casing on write and read to avoid case-mismatch failures.
Lai Wei (weilai-irl)
force-pushed
the
wip-135651-m405
branch
from
August 6, 2026 15:27
7f77230 to
90b9cec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Manually matched users are keyed by Entra UPN, which often differs from the Moodle username. handlelogin() found the matched user but then discarded it, continuing with the UPN as the username and failing with "User not found in Moodle." Now it binds to the matched user's actual username instead. Also normalizes entraidupn casing on write and read to avoid case-mismatch failures.