config: add a new SAML_IDP_ENABLED env var

This fixes the app crashing on launch when using the production profile,
because the certificates are not present.
This commit is contained in:
Pierre de La Morinerie 2022-01-26 11:59:59 +01:00
parent 413f66e144
commit 387701e7cb
3 changed files with 7 additions and 7 deletions

View file

@ -25,7 +25,7 @@ as defined by the routes in the `admin/` namespace
<%= link_to "Delayed Jobs", manager_delayed_job_path, class: "navigation__link" %>
<%= link_to "Features", manager_flipper_path, class: "navigation__link" %>
<% if Rails.env.production? && ENV['SENDINBLUE_ENABLED'] == 'enabled'%>
<% if ENV["SENDINBLUE_ENABLED"] == "enabled" && ENV["SAML_IDP_ENABLED"] == "enabled" %>
<%= link_to "Sendinblue", ENV.fetch("SENDINBLUE_LOGIN_URL"), class: "navigation__link", target: '_blank' %>
<% end %>
</nav>

View file

@ -16,11 +16,6 @@ SECRET_KEY_BASE="05a2d479d8e412198dabd08ef0eee9d6e180f5cbb48661a35fd1cae287f0a93
# Secret key for One-Time-Password codes, used for 2-factors authentication
OTP_SECRET_KEY=""
# SAML IdP
# SAML_IDP_CERTIFICATE="billybop"
# SAML_IDP_SECRET_KEY="-----BEGIN RSA PRIVATE KEY-----\nblabla+blabla\n-----END RSA PRIVATE KEY-----\n"
# Database credentials
DB_DATABASE="tps_development"
DB_HOST="localhost"
@ -41,6 +36,11 @@ FOG_OPENSTACK_URL=""
FOG_OPENSTACK_REGION=""
DS_PROXY_URL=""
# SAML Identity provider
SAML_IDP_ENABLED="disabled"
SAML_IDP_CERTIFICATE=""
SAML_IDP_SECRET_KEY="-----BEGIN RSA PRIVATE KEY-----\nblabla+blabla\n-----END RSA PRIVATE KEY-----\n"
# External service: authentication through France Connect
FC_PARTICULIER_ID=""
FC_PARTICULIER_SECRET=""

View file

@ -1,7 +1,7 @@
# The certificate and secret key are not fetched from secrets.yml because there is a problem to set a secret key from a multiline env var"
# So we fetch env var directly here
if Rails.env.production?
if ENV['SAML_IDP_ENABLED'] == 'enabled'
SamlIdp.config.x509_certificate = ENV.fetch("SAML_IDP_CERTIFICATE")
SamlIdp.config.secret_key = ENV.fetch("SAML_IDP_SECRET_KEY")
end