Skip to content

Ensure email sent to user's stored email - #127388

Merged
michelletran-sentry merged 3 commits into
masterfrom
fix/sso-email-identity-handling
Oct 14, 2026
Merged

michelletran-sentry merged 3 commits into
masterfrom
fix/sso-email-identity-handling

Conversation

@michelletran-sentry

Copy link
Copy Markdown
Contributor

Fix to ensure that we send confirmation email to the user's stored email. Also fixed inconsistencies with email matching.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@michelletran-sentry
michelletran-sentry requested review from a team as code owners October 14, 2026 16:21
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 14, 2026
@michelletran-sentry
michelletran-sentry force-pushed the fix/sso-email-identity-handling branch from bc2e386 to cbb75fc Compare October 14, 2026 16:35
michelletran-sentry and others added 3 commits October 14, 2026 12:38
resolve_email_to_user() matched addresses with email__iexact, which the
database evaluates with its locale-aware UPPER(). That can fold distinct
Unicode code points together (e.g. U+0131, U+017F, U+212A), so which
account an address resolves to depended on the database collation.
Re-filter the candidates with emails_match(), an ASCII-only caseless
comparison that never conflates distinct code points, so resolution is
deterministic regardless of collation.

Co-Authored-By: Claude <[email protected]>
…kups

Propagate emails_match() (an ASCII-only caseless comparison) to the other
places that resolve an email to a user or member via email__iexact, so none
of them depend on the database collation's character folding:

- utils.auth.find_users (login / email fallback)
- user service get_users and get_user_by_email
- organization service check_membership_by_email and get_member

Co-Authored-By: Claude <[email protected]>
The one-time account-confirmation link for IdP migration was mailed to
the raw email asserted by the SSO identity provider, which need not be an
address that belongs to the matched account (account lookup is
case-insensitive). Send the link to an address that belongs to the
account instead: its verified addresses, or its primary address when none
are verified (SSO-provisioned accounts may have no verified email). The
asserted email is retained only as the Redis match token checked by
has_verified_account, so the migration flow is otherwise unchanged.

Add coverage for the send helper and the real SSO pipeline
(handle_unknown_identity -> _dispatch_to_confirmation ->
send_one_time_account_confirm_link).

Co-Authored-By: Claude <[email protected]>
@michelletran-sentry
michelletran-sentry force-pushed the fix/sso-email-identity-handling branch from cbb75fc to c87da40 Compare October 14, 2026 16:39
@michelletran-sentry
michelletran-sentry enabled auto-merge (squash) October 14, 2026 16:42
@michelletran-sentry
michelletran-sentry merged commit 346ec44 into master Oct 14, 2026
88 checks passed
@michelletran-sentry
michelletran-sentry deleted the fix/sso-email-identity-handling branch October 14, 2026 16:55
markatsentry added a commit that referenced this pull request Oct 14, 2026
…rification

Follow-up to #127388. Use the same ASCII-only email comparison in the
remaining user service lookups and tighten the SSO account confirmation
check to the issuing identity.
markatsentry added a commit that referenced this pull request Oct 14, 2026
…rification

Follow-up to #127388. Use the same ASCII-only email comparison in the
remaining user service lookups and tighten the SSO account confirmation
check to the issuing identity.
markatsentry added a commit that referenced this pull request Oct 14, 2026
…rification

Follow-up to #127388. Use the same ASCII-only email comparison in the
remaining user service lookups and tighten the SSO account confirmation
check to the issuing identity.
markatsentry added a commit that referenced this pull request Oct 14, 2026
…rification

Follow-up to #127388. Use the same ASCII-only email comparison in the
remaining user service lookups and tighten the SSO account confirmation
check to the issuing identity.
markatsentry added a commit that referenced this pull request Oct 14, 2026
…rification

Follow-up to #127388. Use the same ASCII-only email comparison in the
remaining user service lookups and tighten the SSO account confirmation
check to the issuing identity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants