Skip to content

ref(auth): Remove legacy login, registration, and MFA handlers - #126712

Merged
evanpurkhiser merged 1 commit into
masterfrom
git/ref-auth-remove-legacy-organization-login-get-handling
Oct 9, 2026
Merged

evanpurkhiser merged 1 commit into
masterfrom
git/ref-auth-remove-legacy-organization-login-get-handling

Conversation

@evanpurkhiser

@evanpurkhiser evanpurkhiser commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

React authentication owns password login, registration, and MFA through the auth APIs. Replace the legacy login view with a React page entry point, remove its password registration and MFA forms, and delete the login, organization-login, auth-link-login, and two-factor templates.

Preserve customer-domain canonicalization, the organization SSO POST pipeline, and partner/channel destination handling. Identity-link GET requests resume canonical organization login with query parameters. The legacy /auth/2fa/ route sends pending MFA back to React while preserving session state, and still completes login when the user has no authenticators. Shared SSO account-confirmation and social-signup forms, the U2F app-ID endpoint, and sudo remain in use.

OAuth consent now uses canonical login via merged #126175. This incorporates the MFA cleanup from superseded #126711. The independent Vercel test update is https://github.com/getsentry/getsentry/pull/22365.

Follow-up frontend removals must deploy afterward: #126757 removes retired login LESS; #126761 removes the template bootstrap hook and rectangular indicator.

Validation: 302 backend authentication, channel-login, MFA, and OAuth tests passed on the combined change. 172 Getsentry tests and nine subtests passed on the combined change. Affected-view type checks and pre-commit checks passed. Six browser MFA tests passed on the combined cleanup, covering TOTP, refresh/resume, incorrect codes, recovery codes, SSO with MFA, and password-reset MFA. Seven login/registration/OAuth browser tests passed on the earlier login cleanup. Browser tests used existing compiled frontend assets.

The independent channel-login redirect encoding fix is tracked in #126862. Land that fix before this cleanup.

Land the inactive-session reactivation fix in #126936 before this cleanup, and preserve its web-entry redirect when rebasing.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 7, 2026
@evanpurkhiser
evanpurkhiser changed the base branch from master to git/ref-auth-always-enable-react-authentication October 7, 2026 14:34
Base automatically changed from git/ref-auth-always-enable-react-authentication to master October 7, 2026 14:43
@evanpurkhiser
evanpurkhiser force-pushed the git/ref-auth-remove-legacy-organization-login-get-handling branch 2 times, most recently from f035c27 to 5741764 Compare October 7, 2026 19:09
@evanpurkhiser evanpurkhiser changed the title ref(auth): Remove legacy organization login GET handling ref(auth): Remove legacy login and registration handlers Oct 7, 2026
@evanpurkhiser
evanpurkhiser force-pushed the git/ref-auth-remove-legacy-organization-login-get-handling branch from 5741764 to 8c4e0d3 Compare October 7, 2026 19:13
evanpurkhiser added a commit that referenced this pull request Oct 7, 2026
Remove the LESS for password/social-login columns and the join-request
tab from the retired Django login templates, including their mobile
overrides.

Land after #126712 has deployed.
Kept separate from the backend removal because frontend and backend
deploy independently.

Audited selector consumers across Sentry source (including provider
templates) and Getsentry. Shared auth containers/footers, provider
logos, org avatars, social-signup radio fields, SSO grids, and the
auth-toggle used by the SAML IdP selector remain live.

Validation: the complete sentry.less entry point compiles successfully;
applicable pre-commit checks passed. This deletes 65 lines from
layout.less.
@evanpurkhiser
evanpurkhiser force-pushed the git/ref-auth-remove-legacy-organization-login-get-handling branch from 8c4e0d3 to 4016d08 Compare October 7, 2026 19:26
@evanpurkhiser evanpurkhiser changed the title ref(auth): Remove legacy login and registration handlers ref(auth): Remove legacy login, registration, and MFA handlers Oct 7, 2026
evanpurkhiser added a commit that referenced this pull request Oct 7, 2026
React registration and password reset use the password strength ring.
Remove the template initialization hook, its configuration type and
test, and the rectangular indicator and its styles. Keep shared zxcvbn
scoring, the ring, and its lazy-loaded React wrapper. Remove the lint
suppression for the deleted styled component.

Land after #126712 has deployed:
the retired organization-login template is the last production caller of
the bootstrap hook. Frontend and backend deploy independently.

Validation: 17 tests passed across the bootstrap queue, registration
form, and password reset suites. Full-project typecheck and pre-commit
checks passed.
@evanpurkhiser
evanpurkhiser force-pushed the git/ref-auth-remove-legacy-organization-login-get-handling branch from 4016d08 to b47b6bc Compare October 8, 2026 14:45
@evanpurkhiser
evanpurkhiser force-pushed the git/ref-auth-remove-legacy-organization-login-get-handling branch from b47b6bc to f84fe69 Compare October 8, 2026 14:50
Comment on lines 57 to +62
def get(self, request: HttpRequest, **kwargs) -> HttpResponseBase:
customer_domain_redirect = self.get_customer_domain_login_redirect(request)
if customer_domain_redirect is not None:
return customer_domain_redirect

if should_render_react_auth(request):
return self.handle_react(request)

next_uri = self.get_next_uri(request=request)
if request.user.is_authenticated:
return self.redirect_authenticated_user(request=request, next_uri=next_uri)

request.session.set_test_cookie()

# Initiate login clears the pending session states so you don't end up at an odd location
initiate_login(request=request, next_url=next_uri)

# Single org mode -- send them to the org-specific handler
if settings.SENTRY_SINGLE_ORGANIZATION:
return self.redirect_to_default_org_login()

session_expired = "session_expired" in request.COOKIES
if session_expired:
messages.add_message(
request=request, level=messages.WARNING, message=WARN_SESSION_EXPIRED
)

if self.should_redirect_to_sso_login(request=request):
response = self.get_org_auth_login_redirect(request=request)
elif self.can_register(request=request):
response = self.get_registration_page(request=request, **kwargs)
else:
response = self.get_login_page(request=request, **kwargs)

if session_expired:
response.delete_cookie("session_expired")

return response

def get_next_uri(self, request: HttpRequest) -> str:
"""
Returns the next URI a user should visit in their authentication flow.
"""
next_uri_fallback = request.session.pop("_next", None)
return request.GET.get(REDIRECT_FIELD_NAME, next_uri_fallback)

def redirect_authenticated_user(self, request: HttpRequest, next_uri: str) -> HttpResponseBase:
"""
If an authenticated user sends a GET request to AuthLoginView, we redirect them forwards in the auth process.
"""
if not request.user.is_active:
return self.redirect(url=reverse("sentry-reactivate-account"))
if is_valid_redirect(url=next_uri, allowed_hosts=(request.get_host(),)):
return self.redirect(url=next_uri)
return self.redirect_to_org(request=request)

def redirect_to_default_org_login(self) -> HttpResponseRedirect:
"""
If Sentry is in single org mode this redirects users to their specific handler.
"""
org = organization_service.get_default_organization()
next_uri = reverse("sentry-auth-organization", args=[org.slug])
return HttpResponseRedirect(redirect_to=next_uri)

def should_redirect_to_sso_login(self, request: HttpRequest) -> bool:
"""
Checks if a GET request to our login page should redirect to SSO login.
"""
non_sso_urls = [
reverse("sentry-auth-organization", args=[request.subdomain]),
reverse("sentry-register"),
]
return (
bool(request.subdomain)
and self.org_exists(request=request)
and request.path_info not in non_sso_urls
)
return self.handle_react(request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Inactive authenticated users no longer redirected to reactivate

AuthPageView.get() dropped the inactive-user redirect, so authenticated inactive sessions hit React auth_config nextUri and bounce between login and auth-required pages. Restore a redirect to sentry-reactivate-account for authenticated inactive users before handle_react, or return that nextUri from auth_config.respond_authenticated.

Evidence
  • Former AuthLoginView.redirect_authenticated_user() redirected when not request.user.is_active to sentry-reactivate-account; that branch was removed from AuthPageView.get().
  • EmailAuthBackend.user_can_authenticate() always returns True, so inactive users keep authenticated sessions (test_reactivate_account.py logs them in).
  • Protected views still treat inactive users as auth-required via BaseView.is_auth_required() and send them to login.
  • React login assigns whatever nextUri auth_config returns for authenticated users, and respond_authenticated() never checks is_active.

Identified by Warden · sentry-backend-bugs · PUT-TQP

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will get a separate fix in for this

@evanpurkhiser
evanpurkhiser marked this pull request as ready for review October 8, 2026 18:47
@evanpurkhiser
evanpurkhiser requested review from a team as code owners October 8, 2026 18:47
@evanpurkhiser
evanpurkhiser merged commit f397575 into master Oct 9, 2026
91 checks passed
@evanpurkhiser
evanpurkhiser deleted the git/ref-auth-remove-legacy-organization-login-get-handling branch October 9, 2026 18:10
evanpurkhiser added a commit that referenced this pull request Oct 15, 2026
The megaphone SVG partial belonged to the legacy organization login
page's “Request to Join” link.
[#126712](#126712) deleted that
page and its include when React authentication replaced the legacy login
views.

Remove the orphaned partial. Current sentry and getsentry code contain
no render calls, includes, inheritance references, or template selectors
consuming `sentry/partial/megaphone.html`.
evanpurkhiser added a commit that referenced this pull request Oct 15, 2026
The partner login banner became unreachable when #126712 removed the
legacy login handler (`f397575c0ba`). That handler provided the sole
`show_partner_login_banner` context value, based on the `partner` query
parameter.

An audit of sentry and getsentry found no remaining setters. Remove the
conditional banner and its dedicated CSS from the alerts partial. Django
flash-message rendering and its `sentry_helpers` dependency remain
intact.
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.

3 participants