Skip to content

Fix OIDC account-linking failing under SameSite=Lax - #3358

Open
Lai Wei (weilai-irl) wants to merge 1 commit into
MOODLE_502_STABLEfrom
wip-135628-m502
Open

Fix OIDC account-linking failing under SameSite=Lax#3358
Lai Wei (weilai-irl) wants to merge 1 commit into
MOODLE_502_STABLEfrom
wip-135628-m502

Conversation

@weilai-irl

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings August 6, 2026 10:44
@weilai-irl Lai Wei (weilai-irl) self-assigned this Aug 6, 2026
@weilai-irl Lai Wei (weilai-irl) added this to the 2026-03 milestone Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Human review recommended

It changes authentication/session restoration behavior (including programmatic login) and should receive a final human security-focused review before approval.

Pull request overview

This PR addresses OIDC account-linking flows where the callback can arrive as a cross-site POST (response_mode=form_post) and a SameSite=Lax Moodle session cookie may not be sent, causing the linking flow to lose the initiating user session.

Changes:

  • Persist the initiating Moodle user id into the OIDC state record when the auth request is initiated from a logged-in (non-guest) user.
  • On callback, recover the initiating user from the state record (falling back to the live session for older state records) and restore the session to that user before proceeding with account linking/migration.
File summaries
File Description
auth/oidc/classes/loginflow/authcode.php Stores the initiating user id in OIDC state and restores the initiating user session during callback handling to survive SameSite=Lax form_post callbacks.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

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.

Linking to M365 account not working in the latest Moodle version

2 participants