在JavaScript中跟踪安全策略权限
尽管设置了以下标题:在JavaScript中跟踪安全策略权限,javascript,iframe,content-security-policy,Javascript,Iframe,Content Security Policy,尽管设置了以下标题: Access-Control-Allow-Origin: * Content-Security-Policy: default-src 'self' 'unsafe-inline' *.speech.is http://bits.speech.is https://bits.speech.is http://speech.is JavaScript仍然阻止我访问iframe.contentWindow.document: Error: Permission denied
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'self' 'unsafe-inline' *.speech.is http://bits.speech.is https://bits.speech.is http://speech.is
JavaScript仍然阻止我访问iframe.contentWindow.document:
Error: Permission denied to access property 'document'
在speech.contentWindow.document之后从Firefox控制台http://bits.speech.is
。Chrome提供了更详细但仍然神秘的信息:
SecurityError: Blocked a frame with origin "http://bits.speech.is" from accessing a frame with origin "http://208.113.212.187". Protocols, domains, and ports must match.
code: 18
message: "Blocked a frame with origin "http://bits.speech.is" from accessing a frame with origin "http://208.113.212.187". Protocols, domains, and ports must match."
name: "SecurityError"
stack: "Error: Blocked a frame with origin "http://bits.speech.is" from accessing a frame with origin "http://208.113.212.187". Protocols, domains, and ports must match.↵ at <anonymous>:2:21↵ at Object.InjectedScript._evaluateOn (<anonymous>:580:39)↵ at Object.InjectedScript._evaluateAndWrap (<anonymous>:539:52)↵ at Object.InjectedScript.evaluate (<anonymous>:458:21)"
SecurityError:阻止了具有原点的帧”http://bits.speech.is“从访问具有原点的帧”http://208.113.212.187". 协议、域和端口必须匹配。
代码:18
消息:“已阻止具有原点的帧”http://bits.speech.is“从访问具有原点的帧”http://208.113.212.187。协议、域和端口必须匹配
名称:“SecurityError”
堆栈:“错误:阻止了具有原点的帧”http://bits.speech.is“从访问具有原点的帧”http://208.113.212.187“。协议、域和端口必须匹配。↵ 两点二十一分↵ 在Object.InjectedScript.\u evaluateOn(:580:39)↵ 在Object.InjectedScript.\u evaluateAndWrap(:539:52)↵ 在Object.InjectedScript.evaluate(:458:21)
是否仍然可以跟踪此安全策略的设置位置?如何找出我还缺少什么?我能找到的微调CSP的最佳方法是这两种方法的组合:
- 查看浏览器控制台
- 将CSP配置为发送CSP报告,因为这些报告有时包含更多的详细信息,这可能会导致控制台消息
报告uri
添加到您的CSP头,我使用唯一的url作为报告收集器。您还可以设置仅内容安全策略报告
变量,直到它开始工作
如果您编写您正在使用的浏览器,它也会有所帮助。这条消息看起来不像是来自Chrome的CSP违规错误-它们比这条消息更详细、更有用。我已经添加了PHP标题,但还没有出现。今天晚些时候我将进行更多调查:)