Business intelligence made simple
Add option to override app-wide csp settings (#209)
Premysl Donat436b6db9c6e9
diff --git a/README.md b/README.mdindex fdda0fff..81c84f01 100644--- a/README.md+++ b/README.md@@ -642,6 +642,10 @@ if (!"AnomalyDetection" %in% installed.packages()) {Commit and deploy away. The first deploy may take a few minutes.+## Content Security Policy++If Blazer views are stuck with "Loading..." message there might be a problem with strict CSP settings in your app. This can be easily checked with Firefox or Chrome dev tools. If this is the case you can tell Blazer to override these settings for it's controllers with `override_csp: true` in `blazer.yml`.+## Upgrading### 1.5diff --git a/app/controllers/blazer/base_controller.rb b/app/controllers/blazer/base_controller.rbindex fbfa2d76..fa98a748 100644--- a/app/controllers/blazer/base_controller.rb+++ b/app/controllers/blazer/base_controller.rb@@ -24,6 +24,12 @@ module Blazerbefore_action Blazer.before_action.to_symend+ if Blazer.override_csp+ after_action do+ response.headers['Content-Security-Policy'] = "default-src 'self' https: 'unsafe-inline' 'unsafe-eval' data:"+ end+ end+layout "blazer/application"privatediff --git a/lib/blazer.rb b/lib/blazer.rbindex 671ef9f5..c588470f 100644--- a/lib/blazer.rb+++ b/lib/blazer.rb@@ -39,6 +39,7 @@ module Blazerattr_accessor :imagesattr_accessor :query_viewableattr_accessor :query_editable+ attr_accessor :override_cspendself.audit = trueself.user_name = :name@@ -46,6 +47,7 @@ module Blazerself.anomaly_checks = falseself.async = falseself.images = false+ self.override_csp = falseTIMEOUT_MESSAGE = "Query timed out :("TIMEOUT_ERRORS = [diff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rbindex 71317293..5b3e5e8b 100644--- a/lib/blazer/engine.rb+++ b/lib/blazer/engine.rb@@ -22,6 +22,7 @@ module BlazerendBlazer.images = Blazer.settings["images"] || false+ Blazer.override_csp = Blazer.settings["override_csp"] || falseendendenddiff --git a/lib/generators/blazer/templates/config.yml.tt b/lib/generators/blazer/templates/config.yml.ttindex 007ef94b..637691de 100644--- a/lib/generators/blazer/templates/config.yml.tt+++ b/lib/generators/blazer/templates/config.yml.tt@@ -57,3 +57,6 @@ check_schedules:- "1 day"- "1 hour"- "5 minutes"++# override app-wide csp for Blazer controllers+override_csp: false