asp.net - 内容安全策略框架祖先在 IE 11 中不起作用
问题描述
目的是阻止其他网站在 iframe 中显示我们网站的内容。
X-Frame-Options = SAMEORIGIN
由于网站的 URL,我无法使用。主要为 www.xyz.com,次要为 sec.xyz.com。
所以我求助于内容安全策略(...代表其他域等)
<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="default-src 'self' localhost ...; script-src 'unsafe-inline' 'unsafe-eval' *; style-src 'unsafe-inline' *; img-src * data; font-src * data:; frame-ancestors 'self' localhost ...;" />
</customHeaders>
</httpProtocol>
FF 和 Chrome 不会在测试页面 iframe 中显示网站。
现在 IE 11 显示 iframe 内的站点,因为不支持 frame-ancestors。https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors
我尝试X-Content-Security-Policy
在全局文件中添加标题,但 IE 11 仍然显示该站点。
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("X-Content-Security-Policy", "frame-ancestors 'self' localhost ...");
}
如何使 IE 11 遵守标题X-Content-Security-Policy
?
解决方案
IE 不frame-ancestors
支持X-Content-Security-Policy
. 使用X-Frame-Options
和使用ALLOW-FROM
.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
推荐阅读
- sql - SQL Server“varchar 值 '99101500728' 的转换溢出了一个 int 列。”
- javascript - 如何从 localforage 获取数据?
- django - 如何在 Django 中处理从 get() 到 filter() 的异常
- css - AMP整页封面背景视频
- groovy - 在构建地图时四舍五入浮点数
- javascript - 对表格进行排序 - React.js
- r - 如何根据具有特定顺序的向量重新排序具有许多列和行的数据框?
- assembly - 8086汇编中给寄存器分配段名是什么意思?
- html - 设置 div 以填充页面并使其在附加时也保持该高度
- closures - Tcl:惯用的[关闭]