Repository navigation
fix(account): match existing users by exact email on OAuth and ID-token sign-in - #14778
Conversation
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change hardens identity matching in three OAuth entry points so users are linked by the provider-reported email (and its lowercase form) rather than the canonicalized local-part-plus-provider-domain address, preventing cross-domain account collisions. It also teaches the mock OAuth
Reviewed commit: 588f2c7 |
🟢 Tier S · Ready to merge
OAuth and ID-token sign-in now match existing accounts using the provider’s exact address and its same-domain normalized form, while retaining canonical email metadata and aliased-email policy checks. The same candidates are used for email backfill collision checks, and the mock OAuth profile can supply arbitrary addresses only in development. E2E coverage exercises case-insensitive matching, separation across Outlook-family domains, and ID-token backfill onto an email-less account. Latest changes: The newest commits limit arbitrary mock OAuth email responses to development and add coverage for ID-token backfill when another Outlook-family domain already owns the canonical alias.
📂 Walkthrough · 4
✅ Fixed since the last review · 1
Reviewed the commits since |
There was a problem hiding this comment.
This PR fixes OAuth canonical-email account matching by matching users only on the provider-reported email instead of the locally canonicalized address, and extends the mock OAuth provider to let tests supply arbitrary verified emails.
Key findings
- 🟡 Mock OAuth endpoint now returns any verified email — mock.php:178
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
fix(account): match existing users by exact email on OAuth and ID-token sign-in (cherry picked from commit 6dcbef4)
Summary
OAuth and ID-token sign-in looked up an existing user by the provider email plus its cross-domain canonical form from
utopia-php/emails(for example, Outlook folds hotmail, live and msn domains into outlook.com). Account matching now uses only the provider's own address: as given, lowercased, and, when canonical emails are enabled for the project, the delivery-safe form that keeps the provider domain. The canonical form is still stored asemailCanonicalmetadata and used by the aliased-email policy.The same list backs the email backfill uniqueness check for users created without an email, so that check now also compares exact addresses.
The mock OAuth provider's
canonical-client ID now returns the address after the prefix when it contains@, so e2e tests can sign in with any address.Test plan
composer lint, PHPStan andcomposer refactor:checkon the changed filestestCreateIdTokenSessionMatchesExactEmail(same address in another case adopts the account; an address on another domain of the same mail provider gets a separate user)testCreateOAuth2SessionMatchesExactEmail(OAuth sign-in with an address on another domain of the same mail provider gets a separate user)Related: appwrite-labs/cloud#6666