diff --git a/app/javascript/components/TypesDeChampEditor/OperationsQueue.js b/app/javascript/components/TypesDeChampEditor/OperationsQueue.js index 166f1891a..46069491d 100644 --- a/app/javascript/components/TypesDeChampEditor/OperationsQueue.js +++ b/app/javascript/components/TypesDeChampEditor/OperationsQueue.js @@ -45,7 +45,7 @@ async function handleError({ response, message }, reject) { try { const { errors: [message] - } = await response.json(); + } = await response.clone().json(); reject(message); } catch { reject(await response.text()); diff --git a/config/env.example.optional b/config/env.example.optional index ea129acc4..2a73be67e 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -93,6 +93,9 @@ DS_ENV="staging" # External service: Matomo web analytics MATOMO_IFRAME_URL="https://matomo.example.org/index.php?module=CoreAdminHome&action=optOut&language=fr&&fontColor=333333&fontSize=16px&fontFamily=Muli" +# An URI used to report requests breaking the Content Security Policy +# CSP_REPORT_URI="https://myappname.report-uri.com/r/d/csp/reportOnly" + # Instance provider # PROVIDED_BY="la DINUM" # PROVIDER_NAME="DINUM" diff --git a/config/initializers/urls.rb b/config/initializers/02_urls.rb similarity index 91% rename from config/initializers/urls.rb rename to config/initializers/02_urls.rb index 7c3fcd282..fd257f272 100644 --- a/config/initializers/urls.rb +++ b/config/initializers/02_urls.rb @@ -1,7 +1,9 @@ # rubocop:disable DS/ApplicationName # API URLs +API_ADRESSE_URL = ENV.fetch("API_ADRESSE_URL", "https://api-adresse.data.gouv.fr") API_ENTREPRISE_URL = ENV.fetch("API_ENTREPRISE_URL", "https://entreprise.api.gouv.fr/v2") API_EDUCATION_URL = ENV.fetch("API_EDUCATION_URL", "https://data.education.gouv.fr/api/records/1.0") +API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr") API_PARTICULIER_URL = ENV.fetch("API_PARTICULIER_URL", "https://particulier.api.gouv.fr/api") HELPSCOUT_API_URL = ENV.fetch("HELPSCOUT_API_URL", "https://api.helpscout.net/v2") PIPEDRIVE_API_URL = ENV.fetch("PIPEDRIVE_API_URL", "https://api.pipedrive.com/v1") @@ -11,7 +13,8 @@ UNIVERSIGN_API_URL = ENV.fetch("UNIVERSIGN_API_URL", "https://ws.universign.eu/t FEATURE_UPVOTE_URL = ENV.fetch("FEATURE_UPVOTE_URL", "https://demarches-simplifiees.featureupvote.com") # Internal URLs -FOG_BASE_URL = "https://static.demarches-simplifiees.fr" +FOG_OPENSTACK_URL = ENV.fetch("FOG_OPENSTACK_URL", "https://auth.cloud.ovh.net") +DS_PROXY_URL = ENV.fetch("DS_PROXY_URL", "") # External services URLs WEBINAIRE_URL = "https://app.livestorm.co/demarches-simplifiees" @@ -44,5 +47,6 @@ FAQ_ERREUR_SIRET_URL = [FAQ_URL, "article", "4-erreur-siret"].join("/") STATUS_PAGE_URL = ENV.fetch("STATUS_PAGE_URL", "https://status.demarches-simplifiees.fr") DEMANDE_INSCRIPTION_ADMIN_PAGE_URL = ENV.fetch("DEMANDE_INSCRIPTION_ADMIN_PAGE_URL", "https://www.demarches-simplifiees.fr/commencer/demande-d-inscription-a-demarches-simplifiees") MATOMO_IFRAME_URL = ENV.fetch("MATOMO_IFRAME_URL", "https://#{ENV.fetch('MATOMO_HOST', 'stats.data.gouv.fr')}/index.php?module=CoreAdminHome&action=optOut&language=fr&&fontColor=333333&fontSize=16px&fontFamily=Muli") +CSP_REPORT_URI = ENV.fetch("CSP_REPORT_URI", "") # rubocop:enable DS/ApplicationName diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 17aa4aef0..279b32ca9 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -4,30 +4,48 @@ # For further information see the following documentation # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy -# rubocop:disable DS/ApplicationName Rails.application.config.content_security_policy do |policy| # Whitelist image - policy.img_src :self, "*.openstreetmap.org", "static.demarches-simplifiees.fr", "*.cloud.ovh.net", "stats.data.gouv.fr", "*", :data, :blob + images_whitelist = ["*.openstreetmap.org", "*.cloud.ovh.net", "*"] + images_whitelist << URI(DS_PROXY_URL).host if DS_PROXY_URL.present? + images_whitelist << URI(MATOMO_IFRAME_URL).host if MATOMO_IFRAME_URL.present? + policy.img_src(:self, :data, :blob, *images_whitelist) + # Whitelist JS: nous, sendinblue et matomo # miniprofiler et nous avons quelques boutons inline :( - policy.script_src :self, "stats.data.gouv.fr", "*.sendinblue.com", "*.crisp.chat", "crisp.chat", "*.sibautomation.com", "sibautomation.com", 'cdn.jsdelivr.net', 'maxcdn.bootstrapcdn.com', 'code.jquery.com', :unsafe_eval, :unsafe_inline, :blob + scripts_whitelist = ["*.sendinblue.com", "*.crisp.chat", "crisp.chat", "*.sibautomation.com", "sibautomation.com", "cdn.jsdelivr.net", "maxcdn.bootstrapcdn.com", "code.jquery.com"] + scripts_whitelist << URI(MATOMO_IFRAME_URL).host if MATOMO_IFRAME_URL.present? + policy.script_src(:self, :unsafe_eval, :unsafe_inline, :blob, *scripts_whitelist) + # Pour les CSS, on a beaucoup de style inline et quelques balises