Merge pull request #10066 from demarches-simplifiees/temp_fix_for_france_connect

Tech: base la l'url de retour de FranceConnect sur le host de la requete
This commit is contained in:
LeSim 2024-03-07 11:35:21 +00:00 committed by GitHub
commit 24fe51220f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View file

@ -28,6 +28,9 @@ class ApplicationController < ActionController::Base
Current.request_id = request.uuid
Current.user = current_user
Current.browser = browser
# TODO: remove this block when migration to new domain is done
# headers['Host'] instead of request.host to keep the port (ex: localhost:3000)
Current.host = request.headers['Host']
end
def staging_authenticate

View file

@ -1,3 +1,3 @@
class Current < ActiveSupport::CurrentAttributes
attribute :user, :request_id, :browser
attribute :user, :request_id, :browser, :host
end

View file

@ -1,6 +1,13 @@
class FranceConnectParticulierClient < OpenIDConnect::Client
def initialize(code = nil)
super(FRANCE_CONNECT[:particulier])
config = FRANCE_CONNECT[:particulier]
# TODO: remove this block when migration to new domain is done
if !Rails.env.test? && Current.host != ENV.fetch("APP_HOST")
config[:redirect_uri] = config[:redirect_uri].gsub(ENV.fetch("APP_HOST"), Current.host)
end
super(config)
if code.present?
self.authorization_code = code