diff options
author | Reverite <github@reverite.sh> | 2019-05-06 18:17:05 -0700 |
---|---|---|
committer | Reverite <github@reverite.sh> | 2019-05-06 18:17:05 -0700 |
commit | 5b85256b334b13fad26a2bc073a874750a3cdc2e (patch) | |
tree | 2d523aa8266e42ae31ab82c7fc2533cf4a90ff0d /config/initializers/content_security_policy.rb | |
parent | e10a9794f4ed7c90e3190f285359f55dd00da435 (diff) | |
parent | 89d2859296bc5a57a8db07be86239cc938a3f691 (diff) |
Merge remote-tracking branch 'glitch/master' into production
Diffstat (limited to 'config/initializers/content_security_policy.rb')
-rw-r--r-- | config/initializers/content_security_policy.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 12b764a5a..2fe1a33fa 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -7,14 +7,24 @@ if Rails.env.production? data_hosts = [assets_host] if ENV['S3_ENABLED'] == 'true' - attachments_host = ENV['S3_ALIAS_HOST'] || ENV['S3_CLOUDFRONT_HOST'] || ENV['S3_HOSTNAME'] || "s3-#{ENV['S3_REGION'] || 'us-east-1'}.amazonaws.com" + attachments_host = "https://#{ENV['S3_ALIAS_HOST'] || ENV['S3_CLOUDFRONT_HOST'] || ENV['S3_HOSTNAME'] || "s3-#{ENV['S3_REGION'] || 'us-east-1'}.amazonaws.com"}" + attachments_host = "https://#{Addressable::URI.parse(attachments_host).host}" elsif ENV['SWIFT_ENABLED'] == 'true' attachments_host = ENV['SWIFT_OBJECT_URL'] + attachments_host = "https://#{Addressable::URI.parse(attachments_host).host}" else attachments_host = nil end + data_hosts << attachments_host unless attachments_host.nil? + if ENV['PAPERCLIP_ROOT_URL'] + url = Addressable::URI.parse(assets_host) + ENV['PAPERCLIP_ROOT_URL'] + data_hosts << "https://#{url.host}" + end + + data_hosts.uniq! + Rails.application.config.content_security_policy do |p| p.base_uri :none p.default_src :none |