Merge pull request #5441 from adullact/5440_allow_to_disable_FranceConnect

Développement : ajout d'une variable d'environnement optionnelle `FRANCE_CONNECT_ENABLED` pour activer ou non France Connect
This commit is contained in:
Pierre de La Morinerie 2020-09-01 16:04:44 +02:00 committed by GitHub
commit 9bfd521a19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 12 deletions

View file

@ -2,7 +2,11 @@ class FranceConnect::ParticulierController < ApplicationController
before_action :redirect_to_login_if_fc_aborted, only: [:callback] before_action :redirect_to_login_if_fc_aborted, only: [:callback]
def login def login
if FranceConnectService.enabled?
redirect_to FranceConnectService.authorization_uri redirect_to FranceConnectService.authorization_uri
else
redirect_to new_user_session_path
end
end end
def callback def callback

View file

@ -1,4 +1,8 @@
class FranceConnectService class FranceConnectService
def self.enabled?
ENV.fetch("FRANCE_CONNECT_ENABLED", "enabled") == "enabled"
end
def self.authorization_uri def self.authorization_uri
client = FranceConnectParticulierClient.new client = FranceConnectParticulierClient.new

View file

@ -1,3 +1,4 @@
- if FranceConnectService.enabled?
.france-connect-login .france-connect-login
%h2 %h2
= t('views.shared.france_connect_login.title') = t('views.shared.france_connect_login.title')
@ -9,3 +10,5 @@
= link_to t('views.shared.france_connect_login.help_link'), "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link" = link_to t('views.shared.france_connect_login.help_link'), "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"
.france-connect-login-separator .france-connect-login-separator
= t('views.shared.france_connect_login.separator') = t('views.shared.france_connect_login.separator')
- else
<!-- FranceConnect is not configured -->

View file

@ -6,6 +6,9 @@ APPLICATION_NAME="demarches-simplifiees.fr"
APPLICATION_SHORTNAME="d-s.fr" APPLICATION_SHORTNAME="d-s.fr"
APPLICATION_BASE_URL="https://www.demarches-simplifiees.fr" APPLICATION_BASE_URL="https://www.demarches-simplifiees.fr"
# Utilisation de France Connect
# FRANCE_CONNECT_ENABLED="disabled" # "enabled" par défaut
# Personnalisation d'instance - Adresses Email de l'application et téléphone # Personnalisation d'instance - Adresses Email de l'application et téléphone
# CONTACT_EMAIL="" # CONTACT_EMAIL=""
# EQUIPE_EMAIL="" # EQUIPE_EMAIL=""