AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.67k stars 2.65k forks source link

Allow passing popup parent for multi-window flows (#7313) #7317

Closed tnorling closed 1 month ago

tnorling commented 1 month ago

Outlook has multi-window scenarios where MSAL code is running in the main window, but being rendered into a popup window. This is interfering with MSAL popup token flows, because the click/user interaction is being done in the popup window, but the call to MSAL acquireTokenPopup is being done in the separate main window, and so when MSAL goes to call window.open, the browser is blocking the popup as the interaction did not occur in the same window and popup_window_error is returned.

The proposed fix is to add a popupWindowParent parameter to the PopupRequest interface, which MSAL will use instead of window when invoking window.open. This makes the browser happy that the popup is being opened and parented to the same window where the interaction occurred. It also fixes UI parenting/z-index issues with the MSAL popup.

If a popupWindowParent is not specified, then today's behaviour is preserved, and window is used.

cc @Salaman