Skip to content

Conversation

@JoshFerge
Copy link
Member

Summary

When users have multiple tabs open on auth pages and log in on one tab, other tabs still show the login form. This PR adds BroadcastChannel-based cross-tab communication to auto-redirect authenticated users.

  • Add organizations:auth-broadcast-channel-redirect feature flag for gradual rollout
  • On login success (SPA flow), broadcast a 'login' message to other tabs
  • Auth pages listen for 'login' messages and reload (server redirects authenticated users)
  • Add visibility change fallback for SSO flows where BroadcastChannel message may be missed

This complements the CSRF token sync fix (#107389) for multi-tab scenarios.

Browser Support

BroadcastChannel is supported in Chrome 54+, Firefox 38+, Safari 15.4+, Edge 79+. Falls back gracefully (visibility change or CSRF sync) on older browsers.

Test Plan

  1. Open two tabs to /auth/login/{org}/
  2. Log in on Tab 1
  3. Tab 2 should immediately reload and redirect (BroadcastChannel)
  4. If BroadcastChannel fails, Tab 2 redirects when focused (visibility change fallback)

Files Changed

  • src/sentry/features/temporary.py - Add feature flag
  • src/sentry/web/frontend/auth_organization_login.py - Pass feature flag to template context
  • src/sentry/templates/sentry/organization-login.html - Expose config to JavaScript
  • src/sentry/templates/sentry/bases/auth.html - Add BroadcastChannel listener + visibility fallback
  • static/app/views/auth/loginForm.tsx - Broadcast login event on success
@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Jan 31, 2026
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

…castChannel

When users have multiple tabs open on auth pages and log in on one tab,
other tabs still show the login form. This adds BroadcastChannel-based
cross-tab communication to auto-redirect authenticated users.

Changes:
- Add `organizations:auth-broadcast-channel-redirect` feature flag
- On login success (SPA flow), broadcast a 'login' message to other tabs
- Auth pages listen for 'login' messages and reload (server redirects auth'd users)
- Add visibility change fallback for SSO flows where BroadcastChannel may miss

This complements the CSRF token sync fix for multi-tab scenarios.
@JoshFerge JoshFerge force-pushed the jferg/auth-broadcast-channel-redirect branch from aa0caf4 to af6f72d Compare January 31, 2026 18:22
@JoshFerge JoshFerge changed the base branch from master to jferg/csrf-token-submit-intercept January 31, 2026 18:22
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 Scope: Frontend Automatically applied to PRs that change frontend components

2 participants