ruby-on-rails - 如何在 Ruby on Rails 中设置特定的 Content-Security-Policy
问题描述
嘿,我有一个 Ror 应用程序,我已经在我的应用程序全局中设置了 CSP,这是我的 config/initilaizers/content_security_policy 中的 CSP 文件
Rails.application.config.content_security_policy do |policy|
policy.default_src :self, :https
policy.font_src :self, :https, :data
policy.img_src :self, :https, :data
policy.object_src :none
policy.script_src :self, :https
policy.style_src :self, :https
end
但我对 ckeditor 和 google 字体有疑问
第一个谷歌字体不会加载字体
第二个ckeditor在这样的样式上有错误
ckeditor.js:94 拒绝应用内联样式,因为它违反了以下内容安全策略指令:“style-src 'self' https:”。启用内联执行需要“unsafe-inline”关键字、哈希(“sha256-ZVjd2zfSTfAVh1y7eCcNk0SPGUQOP/H8vzrFJIVgg90=”)或随机数(“nonce-...”)。
问题是,我可以只为 ckeditor CSP添加特定的unsafe_inline吗?这是因为我只在 rails_admin 中使用这个 CKEditor
为什么在我生成完整性哈希后不会加载谷歌字体?
谢谢
解决方案
推荐阅读
- javascript - OpenWeather API 紫外线指数
- r - R Studio 测试包中使用的变量
- swift - 为什么我不能使用 swift 从本地蒸汽服务获取数据?
- macos - 在 MacOSX 上使用 gnuplot 5.2.8 出现文本问题
- html - CSS悬停过渡,从中心开始的宽度
- swift - Swift Mapkit, How to add tap gesture in custom annotation?
- python - 如何使用 Google colab 将文件下载到 Google Drive?
- scheduled-tasks - Schedule script to attach CSV file report to a data source in servicenow
- xml - XSD基本类型限制有什么问题
- java - 分离实体传递到持久 JPA Spring 引导保存