From 363f70a3fcd7232fc7add44a688550bb143ffcea Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 16 Sep 2024 13:38:09 +0200 Subject: [PATCH] add feature flipping, just in case --- app/controllers/agent_connect/agent_controller.rb | 4 +++- config/initializers/flipper.rb | 1 + spec/controllers/agent_connect/agent_controller_spec.rb | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/agent_connect/agent_controller.rb b/app/controllers/agent_connect/agent_controller.rb index 0ecefb767..93be41843 100644 --- a/app/controllers/agent_connect/agent_controller.rb +++ b/app/controllers/agent_connect/agent_controller.rb @@ -29,7 +29,9 @@ class AgentConnect::AgentController < ApplicationController user_info, id_token, amr = AgentConnectService.user_info(params[:code], cookies.encrypted[NONCE_COOKIE_NAME]) cookies.delete NONCE_COOKIE_NAME - if user_info['idp_id'] == MON_COMPTE_PRO_IDP_ID && !amr.include?('mfa') + if user_info['idp_id'] == MON_COMPTE_PRO_IDP_ID && + !amr.include?('mfa') && + Flipper.enabled?(:agent_connect_2fa, Struct.new(:flipper_id).new(flipper_id: user_info['email'])) # we need the id_token to disconnect the agent connect session later. # we cannot store it in the instructeur model because the user is not yet created # so we store it in a encrypted cookie diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb index 129702860..6c5655878 100644 --- a/config/initializers/flipper.rb +++ b/config/initializers/flipper.rb @@ -20,6 +20,7 @@ end # A list of features to be deployed on first push features = [ :administrateur_web_hook, + :agent_connect_2fa, :api_particulier, :attestation_v2, :blocking_pending_correction, diff --git a/spec/controllers/agent_connect/agent_controller_spec.rb b/spec/controllers/agent_connect/agent_controller_spec.rb index 9c55a82c3..723d68320 100644 --- a/spec/controllers/agent_connect/agent_controller_spec.rb +++ b/spec/controllers/agent_connect/agent_controller_spec.rb @@ -39,6 +39,7 @@ describe AgentConnect::AgentController, type: :controller do context 'and user_info returns some info' do before do expect(AgentConnectService).to receive(:user_info).with(code, nonce).and_return([user_info, id_token, amr]) + Flipper.enable(:agent_connect_2fa) end context 'and the instructeur use mon_compte_pro' do