【问题标题】:Where to declare content security policy report-uri?在哪里声明内容安全策略report-uri?
【发布时间】:2018-07-04 23:11:28
【问题描述】:

我是 Content-Security-Policy 的新手,第一次尝试在我的 Web 应用程序中实现 CSP,但我不知道在哪里放置/声明报告 uri,因为它不能使用 meta 声明http-equiv。

我尝试将此代码放在 .htaccess 文件的最上面一行,但它似乎没有运行 URI。

Header set Content-Security-Policy "report-uri http://localhost/my-webapp-name/report-parser.php"

但如果我手动将某些内容发布到“report-parser.php”,脚本就可以正常工作。

更新: 看来我找到了问题,但仍然没有找到解决方案。我理解的问题是我在 .htaccess 上设置的策略被我使用元 http-equiv 在 html <head></head> 中声明的策略覆盖。

那么问题就变成了,在哪里声明策略report-uri,这样它就不会被html头中的其他策略覆盖?

【问题讨论】:

标签: php apache .htaccess reporting content-security-policy


【解决方案1】:

到目前为止,基于 Dipak cahvda 共享的此链接 https://gist.github.com/phpdave/24d879514e7411047267 的工作解决方案是将所有策略放在 php header() 函数中。

【讨论】:

    猜你喜欢
    • 2017-07-15
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 2020-10-19
    • 2021-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多