我正在向响应头中添加以下内容:
x-content-security-policy default-src 'none';
我期望页面上不会加载任何css或图像,但实际上所有东西都被加载了。我做错了什么?
我正在向响应头中添加以下内容:
x-content-security-policy default-src 'none';
我期望页面上不会加载任何css或图像,但实际上所有东西都被加载了。我做错了什么?
对于Chrome和更新版本的Firefox(v.23及以上):
Content-Security-Policy: default-src 'none'
对于Safari:
X-Webkit-CSP: default-src 'none'
对于较旧的Firefox版本(v. 23及更早版本):
X-Content-Security-Policy: default-src 'none'
抱歉 - 在IE浏览器中,只有sandbox
策略被识别,而且仅在IE 10及更高版本中可用。
Content-Security-Policy: default-src 'none'
Content-Security-Policy:
之前包含 Header set
。就像这样:Header set Content-Security-Policy:
CSP头现在至少有三种不同的风格,而且浏览器版本之间的支持也非常不同。我建议一开始只使用最标准的那个(Content-Security-Policy),并将其设置为报告模式(Content-Security-Policy-Report-Only)。详情请参见https://en.wikipedia.org/wiki/Content_Security_Policy#Status。您还可以尝试使用“迭代”方法来构建您的内容安全策略,使用http://cspbuilder.info/。