Feat: allow to disable France-Connect

Refs: #5440
This commit is contained in:
Fabrice Gangler 2020-08-01 10:33:38 +02:00
parent a4c830da70
commit 1a43f888fb
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=""