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]
def login
redirect_to FranceConnectService.authorization_uri
if FranceConnectService.enabled?
redirect_to FranceConnectService.authorization_uri
else
redirect_to new_user_session_path
end
end
def callback

View file

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

View file

@ -1,11 +1,14 @@
.france-connect-login
%h2
= t('views.shared.france_connect_login.title')
%p
= t('views.shared.france_connect_login.description')
.france-connect-login-buttons
= link_to t('views.shared.france_connect_login.login_button'), url, class: "france-connect-login-button"
.france-connect-help-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
= t('views.shared.france_connect_login.separator')
- if FranceConnectService.enabled?
.france-connect-login
%h2
= t('views.shared.france_connect_login.title')
%p
= t('views.shared.france_connect_login.description')
.france-connect-login-buttons
= link_to t('views.shared.france_connect_login.login_button'), url, class: "france-connect-login-button"
.france-connect-help-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
= 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_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
# CONTACT_EMAIL=""
# EQUIPE_EMAIL=""