X-Frame-Options 和 Content-Security-Policy 用于 Firefox 中的框架
X-Frame-Options and Content-Security-Policy for frames in Firefox
Content Security Policy specification says
The frame-ancestors directive obsoletes the X-Frame-Options header. If a resource has both policies, the frame-ancestors policy SHOULD be enforced and the X-Frame-Options policy SHOULD be ignored.
所以根据我的理解,如果 Content-Security-Policy
和 X-Frame-Options
header 都存在,那么 X-Frame-Options
应该被忽略。
我有一个包含两个 header 的网络应用程序,看起来 Firefox 38 忽略了 Content-Security-Policy
header,而是使用 X-Frame-Options
header。
我的样本 header 是:
Content-Security-Policy:frame-ancestors 'self' local.com *.local.com
X-Frame-Options:Allow-From http://local.com
我希望可以从 local.com 和所有子域访问我的框架。 Local.com 只是一个例子。如果 X-Frame-Options
header 存在,那么它只允许 http://local.com,但如果我删除它,那么 Firefox 将使用 Content-Security-Policy
header 并且对域和子域工作正常.
这是否意味着 Firefox 没有实现这部分?或者它只是太新的规范而 Firefox 还没有实现它?有没有其他方法强制使用 Content-Security-Policy
header?
我知道 Chrome 可以与 Content-Security-Policy
一起正常工作,IE 可以只与 X-Frame-Options
一起工作,但看起来我不能同时使用这两个 header,因为Firefox 运行不正常。
一种可能的方法是只为 IE 发送 X-Frame-Options
,为所有其他发送 Content-Security-Policy
,但是有更好的方法吗?
谢谢!
frame-ancestors
只出现在 CSP Level 2 中(参见 changelog)所以 Firefox 38 很可能还没有实现它。
您可以通过查看 JavaScript 控制台很容易地验证这一点 - 浏览器将显示有关它不理解的每个 CSP 指令的警告。
您也可以从 beta 频道下载 Firefox,看看它是否有所不同,但如果您只是想为生产构建一个可互操作的解决方案,显然它不会有太大帮助网站...
Content Security Policy specification says
The frame-ancestors directive obsoletes the X-Frame-Options header. If a resource has both policies, the frame-ancestors policy SHOULD be enforced and the X-Frame-Options policy SHOULD be ignored.
所以根据我的理解,如果 Content-Security-Policy
和 X-Frame-Options
header 都存在,那么 X-Frame-Options
应该被忽略。
我有一个包含两个 header 的网络应用程序,看起来 Firefox 38 忽略了 Content-Security-Policy
header,而是使用 X-Frame-Options
header。
我的样本 header 是:
Content-Security-Policy:frame-ancestors 'self' local.com *.local.com
X-Frame-Options:Allow-From http://local.com
我希望可以从 local.com 和所有子域访问我的框架。 Local.com 只是一个例子。如果 X-Frame-Options
header 存在,那么它只允许 http://local.com,但如果我删除它,那么 Firefox 将使用 Content-Security-Policy
header 并且对域和子域工作正常.
这是否意味着 Firefox 没有实现这部分?或者它只是太新的规范而 Firefox 还没有实现它?有没有其他方法强制使用 Content-Security-Policy
header?
我知道 Chrome 可以与 Content-Security-Policy
一起正常工作,IE 可以只与 X-Frame-Options
一起工作,但看起来我不能同时使用这两个 header,因为Firefox 运行不正常。
一种可能的方法是只为 IE 发送 X-Frame-Options
,为所有其他发送 Content-Security-Policy
,但是有更好的方法吗?
谢谢!
frame-ancestors
只出现在 CSP Level 2 中(参见 changelog)所以 Firefox 38 很可能还没有实现它。
您可以通过查看 JavaScript 控制台很容易地验证这一点 - 浏览器将显示有关它不理解的每个 CSP 指令的警告。
您也可以从 beta 频道下载 Firefox,看看它是否有所不同,但如果您只是想为生产构建一个可互操作的解决方案,显然它不会有太大帮助网站...