double callback on FC based on the request host

This commit is contained in:
simon lehericey 2024-03-05 16:32:18 +01:00
parent 1f48f7e2dc
commit 8dea936d41
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