Put CSP in enforcing mode
authorTom Hughes <tom@compton.nu>
Tue, 22 May 2018 08:01:13 +0000 (09:01 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 22 May 2018 08:01:56 +0000 (09:01 +0100)
cookbooks/web/recipes/rails.rb
cookbooks/web/resources/rails_port.rb

index d5f34cb..ab6c4e7 100644 (file)
@@ -90,7 +90,7 @@ rails_port "www.openstreetmap.org" do
   mapzen_valhalla_key web_passwords["mapzen_valhalla_key"]
   thunderforest_key web_passwords["thunderforest_key"]
   totp_key web_passwords["totp_key"]
-  csp_report_url "https://openstreetmap.report-uri.io/r/default/csp/reportOnly"
+  csp_enforce true
 end
 
 package "libjson-xs-perl"
index d53cac8..1c95dd8 100644 (file)
@@ -65,6 +65,7 @@ property :mapquest_key, String
 property :mapzen_valhalla_key, String
 property :thunderforest_key, String
 property :totp_key, String
+property :csp_enforce, [TrueClass, FalseClass], :default => false
 property :csp_report_url, String
 property :piwik_configuration, Hash
 
@@ -264,6 +265,10 @@ action :create do
       line.gsub!(/^( *)#totp_key:.*$/, "\\1totp_key: \"#{new_resource.totp_key}\"")
     end
 
+    if new_resource.csp_enforce
+      line.gsub!(/^( *)csp_enforce:.*$/, "\\1csp_enforce: \"#{new_resource.csp_enforce}\"")
+    end
+
     if new_resource.csp_report_url
       line.gsub!(/^( *)#csp_report_url:.*$/, "\\1csp_report_url: \"#{new_resource.csp_report_url}\"")
     end