config: add back DS_PROXY_URL to CSP

Otherwise a bunch of "static.demarches-simplifiees.fr" domains would
be missing.
This commit is contained in:
Pierre de La Morinerie 2022-02-09 12:03:46 +01:00
parent d5f207d98c
commit 0b2775a1a6
2 changed files with 5 additions and 3 deletions

View file

@ -14,6 +14,7 @@ FEATURE_UPVOTE_URL = ENV.fetch("FEATURE_UPVOTE_URL", "https://demarches-simplifi
# Internal URLs # Internal URLs
FOG_OPENSTACK_URL = ENV.fetch("FOG_OPENSTACK_URL", "https://auth.cloud.ovh.net") FOG_OPENSTACK_URL = ENV.fetch("FOG_OPENSTACK_URL", "https://auth.cloud.ovh.net")
DS_PROXY_URL = ENV.fetch("DS_PROXY_URL", "")
# External services URLs # External services URLs
WEBINAIRE_URL = "https://app.livestorm.co/demarches-simplifiees" WEBINAIRE_URL = "https://app.livestorm.co/demarches-simplifiees"

View file

@ -7,7 +7,7 @@
Rails.application.config.content_security_policy do |policy| Rails.application.config.content_security_policy do |policy|
# Whitelist image # Whitelist image
images_whitelist = ["*.openstreetmap.org", "*.cloud.ovh.net", "*"] images_whitelist = ["*.openstreetmap.org", "*.cloud.ovh.net", "*"]
images_whitelist << URI(FOG_OPENSTACK_URL).host if FOG_OPENSTACK_URL.present? images_whitelist << URI(DS_PROXY_URL).host if DS_PROXY_URL.present?
images_whitelist << URI(MATOMO_IFRAME_URL).host if MATOMO_IFRAME_URL.present? images_whitelist << URI(MATOMO_IFRAME_URL).host if MATOMO_IFRAME_URL.present?
policy.img_src(:self, :data, :blob, *images_whitelist) policy.img_src(:self, :data, :blob, *images_whitelist)
@ -23,16 +23,17 @@ Rails.application.config.content_security_policy do |policy|
policy.style_src(:self, "*.crisp.chat", "crisp.chat", 'cdn.jsdelivr.net', 'maxcdn.bootstrapcdn.com', :unsafe_inline) policy.style_src(:self, "*.crisp.chat", "crisp.chat", 'cdn.jsdelivr.net', 'maxcdn.bootstrapcdn.com', :unsafe_inline)
connect_whitelist = ["wss://*.crisp.chat", "*.crisp.chat", "in-automate.sendinblue.com", "app.franceconnect.gouv.fr", "sentry.io", "openmaptiles.geo.data.gouv.fr", "openmaptiles.github.io", "tiles.geo.api.gouv.fr", "wxs.ign.fr"] connect_whitelist = ["wss://*.crisp.chat", "*.crisp.chat", "in-automate.sendinblue.com", "app.franceconnect.gouv.fr", "sentry.io", "openmaptiles.geo.data.gouv.fr", "openmaptiles.github.io", "tiles.geo.api.gouv.fr", "wxs.ign.fr"]
connect_whitelist << ENV.fetch('APP_HOST')
connect_whitelist << URI(DS_PROXY_URL).host if DS_PROXY_URL.present?
connect_whitelist << URI(API_ADRESSE_URL).host if API_ADRESSE_URL.present? connect_whitelist << URI(API_ADRESSE_URL).host if API_ADRESSE_URL.present?
connect_whitelist << URI(API_EDUCATION_URL).host if API_EDUCATION_URL.present? connect_whitelist << URI(API_EDUCATION_URL).host if API_EDUCATION_URL.present?
connect_whitelist << URI(API_GEO_URL).host if API_GEO_URL.present? connect_whitelist << URI(API_GEO_URL).host if API_GEO_URL.present?
connect_whitelist << "*.#{ENV.fetch('APP_HOST', 'localhost:3000')}"
policy.connect_src(:self, *connect_whitelist) policy.connect_src(:self, *connect_whitelist)
# Pour tout le reste, par défaut on accepte uniquement ce qui vient de chez nous # Pour tout le reste, par défaut on accepte uniquement ce qui vient de chez nous
# et dans la notification on inclue la source de l'erreur # et dans la notification on inclue la source de l'erreur
default_whitelist = ["fonts.gstatic.com", "in-automate.sendinblue.com", "player.vimeo.com", "app.franceconnect.gouv.fr", "sentry.io", "*.crisp.chat", "crisp.chat", "*.crisp.help", "*.sibautomation.com", "sibautomation.com", "data"] default_whitelist = ["fonts.gstatic.com", "in-automate.sendinblue.com", "player.vimeo.com", "app.franceconnect.gouv.fr", "sentry.io", "*.crisp.chat", "crisp.chat", "*.crisp.help", "*.sibautomation.com", "sibautomation.com", "data"]
default_whitelist << URI(FOG_OPENSTACK_URL).host if FOG_OPENSTACK_URL.present? default_whitelist << URI(DS_PROXY_URL).host if DS_PROXY_URL.present?
policy.default_src(:self, :data, :blob, :report_sample, *default_whitelist) policy.default_src(:self, :data, :blob, :report_sample, *default_whitelist)
if Rails.env.development? if Rails.env.development?