【发布时间】:2020-10-20 07:20:54
【问题描述】:
正如标题所述,我在使用 x-frame-options: sameorigin 在 iframe 中显示我的页面时遇到问题
查看可能的解决方案时,我遇到了x-frame-options: allow-from url,这并没有什么区别。我的所有资源也通过 https 提供。
当同时使用x-frame-options: sameorigin 和X-Frame-Options: allow-from url 时,sameorigin 标头被禁用。
另外,x-frame-options 上的文档在 here 上找到:
# ALLOW-FROM uri
This is an obsolete directive that no longer works in modern browsers. Don't use it. In
supporting legacy browsers, a page can be displayed in a frame only on the specified origin
uri. Note that in the legacy Firefox implementation this still suffered from the same problem
as SAMEORIGIN did — it doesn't check the frame ancestors to see if they are in the same origin.
The Content-Security-Policy HTTP header has a frame-ancestors directive which you can use
instead.
我目前已实现上述frame-ancestors 以支持其他浏览器,例如。 Chrome、Safari 或 Firefox,但 IE11 不支持。这是一个安全层,我不想删除它以避免点击劫持。
有什么建议吗?
【问题讨论】:
-
您能否告诉我们,您在哪里实现这些响应标头?你只尝试过
x-frame-options: sameorigin吗?这对IE浏览器有效吗?请尝试检查任何资源文件(如 JS、CSS 或任何其他文件)是否使用 HTTP 协议。它可能会导致此错误。 -
我设法找到了一个适用于 IE11 并且不影响其他浏览器的解决方案。这些标头是在服务器端添加的。
标签: iframe ms-word internet-explorer-11 x-frame-options clickjacking