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] before_action :redirect_to_login_if_fc_aborted, only: [:callback]
def login def login
redirect_to FranceConnectService.authorization_uri if FranceConnectService.enabled?
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,11 +1,14 @@
.france-connect-login - if FranceConnectService.enabled?
%h2 .france-connect-login
= t('views.shared.france_connect_login.title') %h2
%p = t('views.shared.france_connect_login.title')
= t('views.shared.france_connect_login.description') %p
.france-connect-login-buttons = t('views.shared.france_connect_login.description')
= link_to t('views.shared.france_connect_login.login_button'), url, class: "france-connect-login-button" .france-connect-login-buttons
.france-connect-help-link = link_to t('views.shared.france_connect_login.login_button'), url, class: "france-connect-login-button"
= link_to t('views.shared.france_connect_login.help_link'), "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link" .france-connect-help-link
.france-connect-login-separator = link_to t('views.shared.france_connect_login.help_link'), "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"
= t('views.shared.france_connect_login.separator') .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=""