Safari blocks cookies when sending data from a child window to a used window that is inside an iframe in the window.opener.postMessage collection.

Hi all. I am a software developer and while developing one of the products (it is a plugin for outlook & outreach) I encountered such a problem. Safari disables cookies when sending data from a child window to a parent window that is inside an iframe when using window.opener.postMessage.

My plugin (React app) works inside iFrame and in order to implement SSO login and not get a block from Azur, I had to create a separate window with SSO login, where the login procedure takes place. After that, the window is closed, and the data required for login, including cookies, is sent to the parent window. The parent window is in an iFrame.

For this operation I use window.open - to open a child window and window.opener.postMessage. - to send data from a child window to a parent window.

parent

const SSOWindowOpen = () => {
    const left = (screen.width - 465 ) / 2
    const top = (screen.height - 650 ) / 4

    const SSOWindow = window.open('/app/static/integrations/ssoWindow', 'SSOWindow',
    'resizable=yes, width=' + 465
    + ', height=' + 650 + ', top='
    + top + ', left=' + left);


    window.addEventListener('message', function(e) {
    SSOFunction(e.data)
    }, false);
  }

Childe

        if (SSOToken) {
            window.opener.postMessage({token: SSOToken}, '/');
            window.close();
        }
    }, [SSOToken])

Tell me, is there a way to solve this problem in a different way or to avoid this blocking? This error does not reproduce in the Chrome browser.

Safari blocks cookies when sending data from a child window to a used window that is inside an iframe in the window.opener.postMessage collection.
 
 
Q