Repository navigation
ref(auth): Apply consistent email matching in user service and SSO verification - #127401
Merged
Merged
Conversation
markatsentry
force-pushed
the
mark/auth-email-matching-followup
branch
4 times, most recently
from
October 14, 2026 18:00
90dd24e to
232cafb
Compare
markatsentry
marked this pull request as ready for review
October 14, 2026 18:44
…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
force-pushed
the
mark/auth-email-matching-followup
branch
from
October 14, 2026 19:56
232cafb to
d84a047
Compare
michelletran-sentry
approved these changes
Oct 14, 2026
markatsentry
enabled auto-merge (squash)
October 14, 2026 20:06
adrianviquez
pushed a commit
that referenced
this pull request
Oct 14, 2026
…rification (#127401) stricter email checking from login sources
This was referenced Oct 15, 2026
joshuarli
pushed a commit
to joshuarli/sentry
that referenced
this pull request
Oct 27, 2026
…ails (getsentry#128720) Two email comparisons still used Python's Unicode-aware lowercasing. Unicode case mapping can turn some non-ASCII characters into ASCII ones (for example, U+212A lowercases to "k"), so a look-alike address could be treated as an existing one. - `AuthIdentityHandler._email_verified_via_pending_invite` compared the SSO identity email to the invited email with `.lower()`. It now uses `emails_match`, the ASCII-only helper from getsentry#127401. - `RegistrationValidator.validate_email` returned `value.lower()`, so a look-alike address was saved as the ASCII address it resembles. It now returns `ascii_casefold(value)`, which lowercases only A-Z. The duplicate-account check in `validate_email` intentionally keeps `iexact`. Postgres `UPPER` matches some look-alikes (for example, "ı" to "I"), and for a uniqueness check, over-matching is the safe direction: it refuses to create a look-alike twin of an existing account.
BYK
added a commit
that referenced
this pull request
Oct 28, 2026
…9114) Follow-up to #128458, from [this review thread](#128458 (comment)). The device-flow `login_hint` check compared the hint to the signed-in user's primary email with `str.casefold()`. Unicode case folding maps some non-ASCII characters onto ASCII. For example, U+212A KELVIN SIGN folds to `k`. So a hint for one address could be approved by an account whose email only looks like it. This switches the check to `sentry.auth.email.emails_match`. That helper folds ASCII A–Z only, and it's what the other auth email comparisons moved to in #127401 and #128720. - `ensure_expected_account` in `oauth_device.py` now calls `emails_match` directly. It was the only caller of `ApiDeviceCode.accepts_user_email`, so I removed that method. The model module can't import `sentry.auth.email` without a cycle, because that module imports `User`, `Organization` and org services. - `test_login_hint_rejects_unicode_lookalike` covers the case. It fails on the old code, which returns 200, and passes with this change, which returns 403. The existing ASCII case-insensitivity test still passes. **Verification:** `test_oauth_device.py` and `test_oauth_device_authorization.py` pass (40 tests). prek and mypy pass on the changed files. <!-- junior-request-attribution:start --> via **BYK**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A7f8efa11623b9416987ceb44 --> -- [View Junior Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A7f8efa11623b9416987ceb44/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <burak.kaya@sentry.io>
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.
stricter email checking from login sources