浏览器现在是否阻止访问跨源 iframe 内的 localStorage?

问题描述 投票:0回答:1

我们使用 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 浏览器的设置配置。

有谁知道我们是否可以使用标头组合来实现此功能?或者这是一种不再有效的设计模式?

http iframe local-storage
1个回答
0
投票

我在广播频道和共享工作人员方面也面临类似的问题。

在 Iframe 中打开的域与在带有共享工作者、广播通道等的新选项卡中独立打开的域之间存在交叉通信问题

这个问题好像最近才出现。

© www.soinside.com 2019 - 2024. All rights reserved.