Skip to content

Conversation

@konstantin-msft
Copy link
Collaborator

@konstantin-msft konstantin-msft commented Oct 29, 2025

This pull request introduces a new "redirect bridge" feature to the MSAL Browser and Common libraries, aimed at improving support for Cross-Origin Opener Policy (COOP) scenarios. It adds new error codes, configuration options, and documentation to guide users on integrating the redirect bridge for authentication flows. The changes also update the build system to package and distribute the bridge scripts. Below are the most important changes grouped by theme:

Redirect Bridge Feature Implementation

  • Implemented the redirect bridge to support COOP, including new builds and exports for the bridge script in package.json and rollup.config.js. [1] [2] [3] [4]

API and Configuration Updates

  • Added new error codes for redirect bridge scenarios (redirectBridgeTimeout, redirectBridgeEmptyResponse, interactionInProgressOverridden) and updated the API surface in msal-browser.api.md. [1] [2] [3] [4]
  • Introduced new configuration options (popupBridgeTimeout, iframeBridgeTimeout) to replace previous timeout settings for popup and iframe interactions. [1] [2]
  • Added new request parameter overrideInteractionInProgress to PopupRequest to allow overriding in-progress interactions.

Public API Additions

  • Exposed new utility methods waitForBridgeResponse and cancelPendingBridgeResponse for managing bridge communication. [1] [2] [3]

Documentation Enhancements

  • Updated docs/errors.md to document new error codes, describe the redirect bridge workflow, troubleshooting steps, and integration guidance for the bridge script. [1] [2] [3]

General Maintenance

  • Updated references and imports throughout the API review file to reflect new types and error codes. [1] [2]

These changes collectively improve authentication reliability in COOP environments and provide clear guidance for developers integrating MSAL with modern browser security policies.

…OP scenario

- Update COOP sample to mock authorize and token endpoints
…OP scenario

- Update COOP sample to mock authorize and token endpoints
…OP scenario

- Update COOP sample to mock authorize and token endpoints
…O scenarios.

- Update COOP sample with additional SSO functionality
…O scenarios.

- Update COOP sample with additional SSO functionality
- Update config params.
- Add bridge error description.
# Conflicts:
#	lib/msal-browser/apiReview/msal-browser.api.md
#	lib/msal-browser/src/interaction_client/PopupClient.ts
#	lib/msal-browser/src/interaction_client/SilentIframeClient.ts
#	lib/msal-browser/src/interaction_handler/SilentHandler.ts
#	lib/msal-browser/test/interaction_client/SilentIframeClient.spec.ts
@konstantin-msft konstantin-msft changed the title Popup COOP implementation Implement redirect bridge to support COOP Nov 6, 2025
@konstantin-msft konstantin-msft marked this pull request as ready for review November 20, 2025 20:33
@konstantin-msft konstantin-msft requested a review from a team as a code owner November 20, 2025 20:33
Copilot AI review requested due to automatic review settings November 20, 2025 20:33

#### How It Works

1. **Main application**: Your COOP-enabled application initiates authentication using `loginPopup()`, `ssoSilent()`, or `loginRedirect()`
Copy link
Member

Choose a reason for hiding this comment

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

Again non blocking comment: Visual helps. We can use mermaid which is super fast to generate visuals and can checkin the source code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added visuals to express and react-router samples. Links and additional docs are located in login-user.md

3. **Authentication flow**: The authority page completes the OAuth flow and receives the auth response
4. **Response handling**: The redirect page uses the new `broadcastResponseToMainFrame()` function which:
- For **popup/silent flows**: Broadcasts the response to the main window via BroadcastChannel API
- For **redirect flows**: Navigates to your application's home page with the auth response
Copy link
Member

Choose a reason for hiding this comment

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

Navigate to page where the acquireTokenRedirect is initiated from correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated doc

this.removeTemporaryItem(key);
} else {
throw createBrowserAuthError(
BrowserAuthErrorCodes.interactionInProgress
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we warn folks that if this happens every time they try interaction, they should allowOverride?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so. This is supposed to be used as a last resort in case user closed popup window.

userInputSystem?.loadFrameTimeout || DEFAULT_POPUP_TIMEOUT_MS,
iframeHashTimeout:
userInputSystem?.loadFrameTimeout || DEFAULT_IFRAME_TIMEOUT_MS,
popupBridgeTimeout:
Copy link
Member

@sameerag sameerag Nov 22, 2025

Choose a reason for hiding this comment

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

I am curious why we have two timeouts. Is it because we want to keep the iframe timeout smaller?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Silent timeout is always shorter because it does not require user interaction

konstantin-msft and others added 22 commits November 24, 2025 13:33
Co-authored-by: Sameera Gajjarapu <sameera.gajjarapu@microsoft.com>
Co-authored-by: Thomas Norling <thomas.norling@microsoft.com>
Co-authored-by: Thomas Norling <thomas.norling@microsoft.com>
Co-authored-by: Thomas Norling <thomas.norling@microsoft.com>
Co-authored-by: Thomas Norling <thomas.norling@microsoft.com>
Co-authored-by: Thomas Norling <thomas.norling@microsoft.com>
- Fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants