You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(auth): Detect SSO provider mismatch and fix 2FA redirect (#106041)
Fixes two issues in the SSO authentication flow:
**Provider mismatch detection**: When users authenticated with the wrong
SSO provider (e.g., Google when the org requires Okta),
`build_identity()` would fail with a confusing error. Now we detect the
mismatch before calling `build_identity()` by comparing the callback's
provider against the org's configured provider, and redirect users to
the correct SSO flow with a clear warning message.
**2FA redirect fix**: The 2FA flow was setting `after_2fa` to the SSO
callback URL instead of the user's original destination. Now it uses
`_next` from the session (validated with `is_valid_redirect()` to
prevent open redirects).
## Changes
- `src/sentry/auth/helper.py`: Add provider mismatch detection in
`finish_pipeline()`, fix `after_2fa` URL in `_login()`
- `src/sentry/auth/providers/oauth2.py`, `saml2/provider.py`: Store
`provider_key` in pipeline state for mismatch detection
0 commit comments