我们使用 iframe 设置来允许跨域持久登录。流程如下。
- Log in to https://a.com
* an authentication token is stored in localStorage
- Go to https://b.com
* An iframe for https://a.com/getToken is loaded
* A window.addEventListener('message', (message) => {...}) message listener is created
* in the iframe a.com gets the token that is stored in localStorage
* a.com uses window.parent.postMessage() to send the token to the b.com parent
这一直工作得很好,但最近停止工作,因为 a.com 在 iframe 中加载时无法访问 localStorage。如果我将 cookie 阻止设置为仅“跨站点跟踪 cookie”而不是“跨站点跟踪 cookie,并隔离其他跨站点 cookie”(在 about:preferences#privacy 下),我就可以在 Firefox 中正常工作。我还没有找到适用于 chromium 浏览器的设置配置。
有谁知道我们是否可以使用标头组合来实现此功能?或者这是一种不再有效的设计模式?