From f84b69276e68446a917012eebd66fb06823280a3 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 11 Feb 2022 15:30:22 +0100 Subject: [PATCH 1/9] fix(expiration_banner.message): miss match when procedure was not expirable ; always showing expiration message --- .../instructeurs/dossiers/_expiration_banner.html.haml | 4 +--- app/views/users/dossiers/_expiration_banner.html.haml | 4 +--- .../dossiers/_expiration_banner.html.haml_spec.rb | 10 ++++++++++ .../dossiers/_expiration_banner.html.haml_spec.rb | 10 ++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/views/instructeurs/dossiers/_expiration_banner.html.haml b/app/views/instructeurs/dossiers/_expiration_banner.html.haml index e1b4329e5..06094b8c4 100644 --- a/app/views/instructeurs/dossiers/_expiration_banner.html.haml +++ b/app/views/instructeurs/dossiers/_expiration_banner.html.haml @@ -23,9 +23,7 @@ = button_to repousser_expiration_instructeur_dossier_path(dossier.procedure, dossier), class: 'button mt-2', id: 'test-instructeur-repousser-expiration' do %span.icon.standby = t('instructeurs.dossiers.header.banner.button_delay_expiration') - - -- else +- elsif dossier.en_instruction? && dossier.procedure.procedure_expires_when_termine_enabled %p.expires_at_en_instruction %small= t("shared.dossiers.header.expires_at.en_instruction") diff --git a/app/views/users/dossiers/_expiration_banner.html.haml b/app/views/users/dossiers/_expiration_banner.html.haml index d2a6e3cdf..79fac0637 100644 --- a/app/views/users/dossiers/_expiration_banner.html.haml +++ b/app/views/users/dossiers/_expiration_banner.html.haml @@ -19,9 +19,7 @@ = button_to users_dossier_repousser_expiration_path(dossier), class: 'button mt-2', id: 'test-user-repousser-expiration' do %span.icon.standby = t('users.dossiers.header.banner.button_delay_expiration', duree_conservation_dossiers_dans_ds: dossier.procedure.duree_conservation_dossiers_dans_ds) - - -- else +- elsif dossier.en_instruction? && dossier.procedure.procedure_expires_when_termine_enabled %p.expires_at_en_instruction %small= t("shared.dossiers.header.expires_at.en_instruction") diff --git a/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb b/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb index e1434fb5f..f3291323d 100644 --- a/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb +++ b/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb @@ -23,6 +23,16 @@ describe 'instructeur/dossiers/expiration_banner.html.haml', type: :view do it 'render estimated expiration date' do expect(subject).not_to have_selector('.expires_at') end + + context 'with dossier.en_instruction?' do + let(:state) { :en_instruction } + let(:attributes) { {} } + + it 'does not render estimated expiration date' do + expect(subject).not_to have_selector('p.expires_at_en_instruction', + text: I18n.t("shared.dossiers.header.expires_at.en_instruction")) + end + end end context 'with procedure having procedure_expires_when_termine_enabled enabled' do diff --git a/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb b/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb index 8bf0c3d51..5703e4cdb 100644 --- a/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb +++ b/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb @@ -24,6 +24,16 @@ describe 'users/dossiers/expiration_banner.html.haml', type: :view do it 'render estimated expiration date' do expect(subject).not_to have_selector('.expires_at') end + + context 'with dossier.en_instruction?' do + let(:state) { :en_instruction } + let(:attributes) { {} } + + it 'does not render estimated expiration date' do + expect(subject).not_to have_selector('p.expires_at_en_instruction', + text: I18n.t("shared.dossiers.header.expires_at.en_instruction")) + end + end end context 'with procedure having procedure_expires_when_termine_enabled enabled' do From ac915494df1242688c582ecdc3b887f4ce911b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Vantomme?= Date: Wed, 26 Jan 2022 16:45:33 +0100 Subject: [PATCH 2/9] feat(landing): hide testimonial & users sections --- app/views/root/_testimonials.html.haml | 51 ++++++++++++++ app/views/root/_users.html.haml | 37 ++++++++++ app/views/root/administration.html.haml | 90 +------------------------ config/env.example.optional | 4 ++ config/initializers/landing.rb | 3 + 5 files changed, 97 insertions(+), 88 deletions(-) create mode 100644 app/views/root/_testimonials.html.haml create mode 100644 app/views/root/_users.html.haml create mode 100644 config/initializers/landing.rb diff --git a/app/views/root/_testimonials.html.haml b/app/views/root/_testimonials.html.haml new file mode 100644 index 000000000..ea3cfe634 --- /dev/null +++ b/app/views/root/_testimonials.html.haml @@ -0,0 +1,51 @@ +.landing-panel + .container + %h2.landing-panel-title Ce que les utilisateurs pensent du service + + %ul.quotes + %li.quote + %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } + .quote-content-wrapper + %p.quote-content + Les échanges avec les usagers sont facilités, ce qui permet de réduire les délais d’instructions et de gagner en efficacité. + + %p.quote-author + %span.quote-author-name Elodie Le Rhun + %br + Cheffe de bureau, DRIEA Ile-de-France + + %li.quote + %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } + .quote-content-wrapper + %p.quote-content + Un service qui garantit une économie de temps et beaucoup moins de manipulations des dossiers. + + %p.quote-author + %span.quote-author-name Nadja Briki + %br + Déléguée de la Préfète du Pas-de-Calais + + %ul.quotes + %li.quote + %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } + .quote-content-wrapper + %p.quote-content + Parfait, cela fonctionne très bien ! Merci encore pour votre réactivité. + + %p.quote-author + %span.quote-author-name Max A. + %br + à notre service support + + %li.quote + %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } + .quote-content-wrapper + %p.quote-content + ★★★★★ + %br + Eh les cocos, il y a la télé-procédure + + %p.quote-author + %span.quote-author-name Hisham M. + %br + sur le site de la DRIEA diff --git a/app/views/root/_users.html.haml b/app/views/root/_users.html.haml new file mode 100644 index 000000000..f02bee547 --- /dev/null +++ b/app/views/root/_users.html.haml @@ -0,0 +1,37 @@ +.landing-panel.users-panel + .container + %h2.landing-panel-title Ils utilisent déjà #{APPLICATION_NAME} + + %ul.users + %li.user + = link_to "https://www.ecologique-solidaire.gouv.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/mtes.jpg"), alt: "Ministère de la Transition Écologique et Solidaire" } + %li.user + = link_to "https://www.iledefrance.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/region-idf.jpg"), alt: "Région Île-de-France" } + %li.user + = link_to "http://www.artisanat.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/chambres-de-metiers.jpg"), alt: "Chambres des Métiers et de l'Artisanat" } + %li.user + = link_to "http://www.cci.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/cci.jpg"), alt: "CCI de France" } + %li.user + = link_to "http://www.driea.ile-de-france.developpement-durable.gouv.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/driea-idf.jpg"), alt: "Direction Régionale et Interdépartementale de l'Équipement et de l'Aménagement" } + + %ul.users + %li.user + = link_to "https://www.debatpublic.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/cndp.jpg"), alt: "Commission Nationale du Débat Public" } + %li.user + = link_to "https://www.iledefrance.ars.sante.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/ars-idf.jpg"), alt: "Agence Régionale de Santé d’Île-de-France" } + %li.user + = link_to "http://www.franceagrimer.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/france-agrimer.jpg"), alt: "FranceAgrimer" } + %li.user + = link_to "http://www.rhone.gouv.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/prefecture-rhone.jpg"), alt: "Préfecture de la région Rhône-Alpes" } + %li.user + = link_to "http://www.lillemetropole.fr/", target: :blank, rel: "noopener noreferrer" do + %img.user-image{ :src => image_url("landing/users/mel.jpg"), alt: "Métropole Européenne de Lille" } diff --git a/app/views/root/administration.html.haml b/app/views/root/administration.html.haml index ae1e27cff..4969a4116 100644 --- a/app/views/root/administration.html.haml +++ b/app/views/root/administration.html.haml @@ -82,57 +82,7 @@ %br à l'ensemble des services de l'État plateforme - .landing-panel - .container - %h2.landing-panel-title Ce que les utilisateurs pensent du service - - %ul.quotes - %li.quote - %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } - .quote-content-wrapper - %p.quote-content - Les échanges avec les usagers sont facilités, ce qui permet de réduire les délais d’instructions et de gagner en efficacité. - - %p.quote-author - %span.quote-author-name Elodie Le Rhun - %br - Cheffe de bureau, DRIEA Ile-de-France - - %li.quote - %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } - .quote-content-wrapper - %p.quote-content - Un service qui garantit une économie de temps et beaucoup moins de manipulations des dossiers. - - %p.quote-author - %span.quote-author-name Nadja Briki - %br - Déléguée de la Préfète du Pas-de-Calais - - %ul.quotes - %li.quote - %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } - .quote-content-wrapper - %p.quote-content - Parfait, cela fonctionne très bien ! Merci encore pour votre réactivité. - - %p.quote-author - %span.quote-author-name Max A. - %br - à notre service support - - %li.quote - %img.quote-quotation-mark{ :src => image_url("landing/testimonials/quotation-mark.svg"), alt: "" } - .quote-content-wrapper - %p.quote-content - ★★★★★ - %br - Eh les cocos, il y a la télé-procédure - - %p.quote-author - %span.quote-author-name Hisham M. - %br - sur le site de la DRIEA + = render partial: "root/testimonials" if LANDING_TESTIMONIALS_ENABLED - cache "numbers-panel", :expires_in => 3.hours do .landing-panel.numbers-panel @@ -161,43 +111,7 @@ %br<> des délais de traitement - .landing-panel.users-panel - .container - %h2.landing-panel-title Ils utilisent déjà #{APPLICATION_NAME} - - %ul.users - %li.user - = link_to "https://www.ecologique-solidaire.gouv.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/mtes.jpg"), alt: "Ministère de la Transition Écologique et Solidaire" } - %li.user - = link_to "https://www.iledefrance.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/region-idf.jpg"), alt: "Région Île-de-France" } - %li.user - = link_to "http://www.artisanat.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/chambres-de-metiers.jpg"), alt: "Chambres des Métiers et de l'Artisanat" } - %li.user - = link_to "http://www.cci.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/cci.jpg"), alt: "CCI de France" } - %li.user - = link_to "http://www.driea.ile-de-france.developpement-durable.gouv.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/driea-idf.jpg"), alt: "Direction Régionale et Interdépartementale de l'Équipement et de l'Aménagement" } - - %ul.users - %li.user - = link_to "https://www.debatpublic.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/cndp.jpg"), alt: "Commission Nationale du Débat Public" } - %li.user - = link_to "https://www.iledefrance.ars.sante.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/ars-idf.jpg"), alt: "Agence Régionale de Santé d’Île-de-France" } - %li.user - = link_to "http://www.franceagrimer.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/france-agrimer.jpg"), alt: "FranceAgrimer" } - %li.user - = link_to "http://www.rhone.gouv.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/prefecture-rhone.jpg"), alt: "Préfecture de la région Rhône-Alpes" } - %li.user - = link_to "http://www.lillemetropole.fr/", target: :blank, rel: "noopener noreferrer" do - %img.user-image{ :src => image_url("landing/users/mel.jpg"), alt: "Métropole Européenne de Lille" } + = render partial: "root/users" if LANDING_USERS_ENABLED .landing-panel.cta-panel-2 .container diff --git a/config/env.example.optional b/config/env.example.optional index c91da1971..ea129acc4 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -102,3 +102,7 @@ MATOMO_IFRAME_URL="https://matomo.example.org/index.php?module=CoreAdminHome&act # PROVIDER_LOGO_ALT="Logo DINUM" # PROVIDER_LOGO_HEIGHT="161" # PROVIDER_LOGO_WIDTH="138" + +# Landing page sections +# LANDING_TESTIMONIALS_ENABLED="enabled" +# LANDING_USERS_ENABLED="enabled" diff --git a/config/initializers/landing.rb b/config/initializers/landing.rb new file mode 100644 index 000000000..d58938b86 --- /dev/null +++ b/config/initializers/landing.rb @@ -0,0 +1,3 @@ +# Hide or show the landing page sections +LANDING_TESTIMONIALS_ENABLED = ENV.fetch("LANDING_TESTIMONIALS_ENABLED", "enabled") == "enabled" +LANDING_USERS_ENABLED = ENV.fetch("LANDING_USERS_ENABLED", "enabled") == "enabled" From 0758e2d1cf1c99a6d736095a0aa3b5b7d58f5a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Vantomme?= Date: Thu, 11 Mar 2021 11:38:51 +0100 Subject: [PATCH 3/9] Refactor: use APP_HOST env variable in development env It prevents exceptions when APP_HOST is custom in development env. *** ArgumentError Exception: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true --- config/environments/development.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index e0be95cc4..ca4b53b87 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -77,15 +77,12 @@ Rails.application.configure do # Action Mailer settings config.action_mailer.delivery_method = :letter_opener - config.action_mailer.default_url_options = { - host: 'localhost', - port: 3000 - } - config.action_mailer.asset_host = "http://" + ENV['APP_HOST'] + config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST") } + config.action_mailer.asset_host = "http://" + ENV.fetch("APP_HOST") Rails.application.routes.default_url_options = { - host: 'localhost', - port: 3000 + host: ENV.fetch("APP_HOST"), + protocol: :http } # Use Content-Security-Policy-Report-Only headers @@ -111,4 +108,6 @@ Rails.application.configure do if ENV['IGN_CARTE_REFERER'] config.hosts << ENV['IGN_CARTE_REFERER'] end + + config.hosts << ENV.fetch("APP_HOST") end From b87154027e2df6295538ad16ef931a43fbc0ae29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Feb 2022 08:02:40 +0000 Subject: [PATCH 4/9] chore(deps): bump follow-redirects from 1.14.7 to 1.14.8 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c2b08ad84..e74c9f9b2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6345,9 +6345,9 @@ folder-walker@^3.2.0: from2 "^2.1.0" follow-redirects@^1.0.0: - version "1.14.7" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685" - integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ== + version "1.14.8" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" + integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA== for-in@^1.0.2: version "1.0.2" From 97feca6305c61870ac0ac583672cdd3d59a704a3 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 28 Jan 2022 16:20:11 +0100 Subject: [PATCH 5/9] feat(ClamAV): add config to disable clamav usage --- app/services/clamav_service.rb | 12 +++--- config/application.rb | 4 ++ config/env.example | 3 ++ spec/services/clamav_service_spec.rb | 56 ++++++++++++++++++++-------- 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/app/services/clamav_service.rb b/app/services/clamav_service.rb index 7acae2a0a..5b7032a55 100644 --- a/app/services/clamav_service.rb +++ b/app/services/clamav_service.rb @@ -1,18 +1,18 @@ class ClamavService def self.safe_file?(file_path) - if Rails.env.development? - return true - end + return true if !Rails.configuration.x.clamav.enabled FileUtils.chmod(0666, file_path) client = ClamAV::Client.new response = client.execute(ClamAV::Commands::ScanCommand.new(file_path)).first - if response.class == ClamAV::SuccessResponse + + case response + when ClamAV::SuccessResponse true - elsif response.class == ClamAV::VirusResponse + when ClamAV::VirusResponse false - elsif response.class == ClamAV::ErrorResponse + when ClamAV::ErrorResponse raise "ClamAV ErrorResponse : #{response.error_str}" else raise "ClamAV unkown response #{response.class.name}" diff --git a/config/application.rb b/config/application.rb index 2d9b15e9f..b75d4ae9b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -76,5 +76,9 @@ module TPS } config.skylight.probes += [:graphql] + + # Custom Configuration + # @see https://guides.rubyonrails.org/configuring.html#custom-configuration + config.x.clamav.enabled = ENV.fetch("CLAMAV_ENABLED", "enabled") == "enabled" end end diff --git a/config/env.example b/config/env.example index f557df768..bd3bd9ff6 100644 --- a/config/env.example +++ b/config/env.example @@ -138,3 +138,6 @@ ENCRYPTION_SERVICE_SALT="" # Salt for invisible_captcha session data. # Must be the same value for all app instances behind a load-balancer. INVISIBLE_CAPTCHA_SECRET="kikooloool" + +# Clamav antivirus usage +CLAMAV_ENABLED="disabled" diff --git a/spec/services/clamav_service_spec.rb b/spec/services/clamav_service_spec.rb index 2341f2229..5c6c028f3 100644 --- a/spec/services/clamav_service_spec.rb +++ b/spec/services/clamav_service_spec.rb @@ -4,25 +4,51 @@ describe ClamavService do subject { ClamavService.safe_file?(path_file) } - before do - client = double("ClamAV::Client", execute: [response]) - allow(ClamAV::Client).to receive(:new).and_return(client) - allow(FileUtils).to receive(:chmod).with(0666, path_file).and_return(true) + context "when ClamAV is enabled" do + before do + @saved_clamav = Rails.configuration.x.clamav.enabled + Rails.configuration.x.clamav.enabled = true + + client = double("ClamAV::Client", execute: [response]) + allow(ClamAV::Client).to receive(:new).and_return(client) + allow(FileUtils).to receive(:chmod).with(0666, path_file).and_return(true) + end + + after do + Rails.configuration.x.clamav.enabled = @saved_clamav + end + + context 'When response type is ClamAV::SuccessResponse' do + let(:response) { ClamAV::SuccessResponse.new("OK") } + it { expect(subject).to eq(true) } + end + + context 'When response type is ClamAV::VirusResponse' do + let(:response) { ClamAV::VirusResponse.new("KO", "VirusN4ame") } + it { expect(subject).to eq(false) } + end + + context 'When response type is ClamAV::ErrorResponse' do + let(:response) { ClamAV::ErrorResponse.new("File not found") } + it { expect { subject }.to raise_error("ClamAV ErrorResponse : File not found") } + end end - context 'When response type is ClamAV::SuccessResponse' do - let(:response) { ClamAV::SuccessResponse.new("OK") } - it { expect(subject).to eq(true) } - end + context "when ClamAV is disabled" do + before do + @saved_clamav = Rails.configuration.x.clamav.enabled + Rails.configuration.x.clamav.enabled = false + end - context 'When response type is ClamAV::VirusResponse' do - let(:response) { ClamAV::VirusResponse.new("KO", "VirusN4ame") } - it { expect(subject).to eq(false) } - end + after do + Rails.configuration.x.clamav.enabled = @saved_clamav + end - context 'When response type is ClamAV::ErrorResponse' do - let(:response) { ClamAV::ErrorResponse.new("File not found") } - it { expect { subject }.to raise_error("ClamAV ErrorResponse : File not found") } + it do + expect(ClamAV::Client).not_to receive(:new) + expect(FileUtils).not_to receive(:chmod) + expect(subject).to eq(true) + end end end end From cc6cb2ea3023e6b2ce14a709a20bfb6d5cbb5945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Vantomme?= Date: Wed, 26 Jan 2022 13:57:49 +0100 Subject: [PATCH 6/9] feat(matomo): use env variables to set the domain --- app/controllers/application_controller.rb | 2 ++ app/javascript/shared/track/matomo.js | 6 +++--- config/env.example | 2 ++ config/secrets.yml | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d7bc6e32a..3fbbef21a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -276,6 +276,8 @@ class ApplicationController < ActionController::Base matomo = Rails.application.secrets.matomo { + cookie_domain: matomo[:cookie_domain], + domain: matomo[:domain], enabled: matomo[:enabled], host: matomo[:host], key: matomo[:client_key] diff --git a/app/javascript/shared/track/matomo.js b/app/javascript/shared/track/matomo.js index 38f3b9b12..c3ca679e6 100644 --- a/app/javascript/shared/track/matomo.js +++ b/app/javascript/shared/track/matomo.js @@ -1,4 +1,4 @@ -const { enabled, host, key } = gon.matomo || {}; +const { cookieDomain, domain, enabled, host, key } = gon.matomo || {}; if (enabled) { window._paq = window._paq || []; @@ -10,8 +10,8 @@ if (enabled) { // Configure Matomo analytics // - window._paq.push(['setCookieDomain', '*.www.demarches-simplifiees.fr']); - window._paq.push(['setDomains', ['*.www.demarches-simplifiees.fr']]); + window._paq.push(['setCookieDomain', cookieDomain]); + window._paq.push(['setDomains', [domain]]); // Don’t store any cookies or send any tracking request when the "Do Not Track" browser setting is enabled. window._paq.push(['setDoNotTrack', true]); // When enabling external link tracking, consider that it will also report links to attachments. diff --git a/config/env.example b/config/env.example index bd3bd9ff6..4c6bb5cb0 100644 --- a/config/env.example +++ b/config/env.example @@ -67,6 +67,8 @@ SENTRY_DSN_JS="" # External service: Matomo web analytics MATOMO_ENABLED="disabled" +MATOMO_COOKIE_DOMAIN="*.www.demarches-simplifiees.fr" +MATOMO_DOMAIN="*.www.demarches-simplifiees.fr" MATOMO_ID="" MATOMO_HOST="matomo.example.org" diff --git a/config/secrets.yml b/config/secrets.yml index c38d4ab90..d0eade23d 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -54,6 +54,8 @@ defaults: &defaults smtp_key: <%= ENV['SENDINBLUE_SMTP_KEY'] %> api_v3_key: <%= ENV['SENDINBLUE_API_V3_KEY'] %> matomo: + cookie_domain: "<%= ENV['MATOMO_COOKIE_DOMAIN'] %>" + domain: "<%= ENV['MATOMO_DOMAIN'] %>" enabled: <%= ENV['MATOMO_ENABLED'] == 'enabled' %> host: <%= ENV['MATOMO_HOST'] %> client_key: <%= ENV['MATOMO_ID'] %> From 31996c7d09b5fe11474dcabc69e1ab1137f77b84 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 25 Jan 2022 15:14:58 +0100 Subject: [PATCH 7/9] chore(smtp): add mailcatcher configuration --- config/env.example | 8 +++++++- config/environments/production.rb | 3 ++- config/initializers/mailcatcher.rb | 13 +++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 config/initializers/mailcatcher.rb diff --git a/config/env.example b/config/env.example index 4c6bb5cb0..9a3fc6d54 100644 --- a/config/env.example +++ b/config/env.example @@ -90,11 +90,17 @@ SENDINBLUE_BALANCING="disabled" SENDINBLUE_BALANCING_VALUE="50" # Alternate SMTP Provider: Mailtrap (mail catcher for staging environments) -# When enabled, all emails will be sent using this provided +# When enabled, all emails will be sent using this provider MAILTRAP_ENABLED="disabled" MAILTRAP_USERNAME="" MAILTRAP_PASSWORD="" +# Alternative SMTP Provider: Mailcatcher (Catches mail and serves it through a dream.) +# When enabled, all emails will be sent using this provider +MAILCATCHER_ENABLED="disabled" +MAILCATCHER_HOST="" +MAILCATCHER_PORT="" + # External service: live chat for admins (specific to démarches-simplifiées.fr) CRISP_ENABLED="disabled" CRISP_CLIENT_KEY="" diff --git a/config/environments/production.rb b/config/environments/production.rb index 912426727..9c541639d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -89,7 +89,8 @@ Rails.application.configure do elsif ENV['SENDINBLUE_ENABLED'] == 'enabled' config.action_mailer.delivery_method = :sendinblue - + elsif ENV['MAILCATCHER_ENABLED'] == 'enabled' + config.action_mailer.delivery_method = :mailcatcher else config.action_mailer.delivery_method = :mailjet end diff --git a/config/initializers/mailcatcher.rb b/config/initializers/mailcatcher.rb new file mode 100644 index 000000000..8b931f704 --- /dev/null +++ b/config/initializers/mailcatcher.rb @@ -0,0 +1,13 @@ +if ENV.fetch('MAILCATCHER_ENABLED') == 'enabled' + ActiveSupport.on_load(:action_mailer) do + module Mailcatcher + class SMTP < ::Mail::SMTP; end + end + + ActionMailer::Base.add_delivery_method :mailcatcher, Mailcatcher::SMTP + ActionMailer::Base.mailcatcher_settings = { + address: ENV.fetch("MAILCATCHER_HOST"), + port: ENV.fetch("MAILCATCHER_PORT") + } + end +end From a2c04a80aa19b832197542da6ce262fe88d80733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Vantomme?= Date: Mon, 31 Jan 2022 14:27:50 +0100 Subject: [PATCH 8/9] refactor(storage): harmonize environment variables Use STORAGE_TYPE everywhere rather than FOG_ENABLED. STORAGE_TYPE is more flexible and is the reference variable for production environment. --- config/env.example | 12 ++++++++++-- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config/env.example b/config/env.example index 9a3fc6d54..1a931103d 100644 --- a/config/env.example +++ b/config/env.example @@ -28,8 +28,16 @@ BASIC_AUTH_ENABLED="disabled" BASIC_AUTH_USERNAME="" BASIC_AUTH_PASSWORD="" -# Object Storage for attachments -FOG_ENABLED="disabled" +# ActiveStorage service to use for attached files. +# Possible values: +# - "local": store files on the local filesystem +# - "amazon": store files remotely on an S3 storage service +# - "openstack": store files remotely on an OpenStack storage service +# +# (See config/storage.yml for the configuration of each service.) +STORAGE_TYPE="local" + +# Configuration for the OpenStack storage service (if enabled) FOG_OPENSTACK_API_KEY="" FOG_OPENSTACK_USERNAME="" FOG_OPENSTACK_URL="" diff --git a/config/environments/development.rb b/config/environments/development.rb index ca4b53b87..6cd35bccc 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,7 +40,7 @@ Rails.application.configure do config.action_mailer.raise_delivery_errors = false # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = ENV['FOG_ENABLED'] == 'enabled' ? :openstack : :local + config.active_storage.service = ENV.fetch("STORAGE_TYPE").to_sym # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index 9c541639d..3a23d77fd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -107,7 +107,7 @@ Rails.application.configure do # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - config.active_storage.service = :openstack + config.active_storage.service = ENV.fetch("STORAGE_TYPE").to_sym # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify From 7425a08e744587b6b5b19f06888f8a9a4165105d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Vantomme?= Date: Tue, 15 Feb 2022 09:33:01 +0000 Subject: [PATCH 9/9] refactor(openstack): rename STORAGE_TYPE to ACTIVE_STORAGE_SERVICE --- config/env.example | 2 +- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/env.example b/config/env.example index 1a931103d..c850f6de5 100644 --- a/config/env.example +++ b/config/env.example @@ -35,7 +35,7 @@ BASIC_AUTH_PASSWORD="" # - "openstack": store files remotely on an OpenStack storage service # # (See config/storage.yml for the configuration of each service.) -STORAGE_TYPE="local" +ACTIVE_STORAGE_SERVICE="local" # Configuration for the OpenStack storage service (if enabled) FOG_OPENSTACK_API_KEY="" diff --git a/config/environments/development.rb b/config/environments/development.rb index 6cd35bccc..ba0946324 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,7 +40,7 @@ Rails.application.configure do config.action_mailer.raise_delivery_errors = false # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = ENV.fetch("STORAGE_TYPE").to_sym + config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE").to_sym # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index 3a23d77fd..b72f7e332 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -107,7 +107,7 @@ Rails.application.configure do # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - config.active_storage.service = ENV.fetch("STORAGE_TYPE").to_sym + config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE").to_sym # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify