我用的是带瓶护身符的烧瓶。我的CSP当前配置为,所有路由为:
SELF = '\'self\''
csp = {
'default-src': [SELF, '*.gstatic.com'],
'connect-src': [SELF, 'https://fonts.googleapis.com', 'https://cdnjs.cloudflare.com'],
'frame-src': [SELF, 'https://js.stripe.com'],
'script-src': [SELF, 'https://cdnjs.cloudflare.com', 'https://js.stripe.com', 'https://www.googletagmanager.com'],
'style-src': [SELF, 'https://cdnjs.cloudflare.com', 'https://fonts.googleapis.com', '\'unsafe-inline\''],
'img-src': [SELF, '*', 'blob:', 'data:']
}
talisman.init_app(app, content_security_policy=csp, content_security_policy_nonce_in=['script-src'])
每当外部站点试图通过iframe
加载我的页面时,它们会收到错误X-Frame-Options is SAMEORIGIN
,这通常是正常的。在
但是,我希望加载外部iframe可以访问单个路由。为了实现这一点,我遵循以下建议:
^{pr2}$在我的具体路线之前。在
但是Chrome不允许这样做,并报告错误。我认为应该设置CSP。我应该如何重新编写或重新配置路由以允许外部iframe在所有浏览器中访问它?在
解决方案是直接在路由上增加一个
frame-ancestors
头,而不是在某些浏览器(inc chrome)中优先使用。在烧瓶护身符路线示例:
https://github.com/GoogleCloudPlatform/flask-talisman/blob/master/example_app/main.py
相关问题 更多 >
编程相关推荐