[PATCH/foreman 1/1] fixes-1300-with-REMOTE_USER-support

Signed-off-by: Romain Vrignaud <romain@yakaz.com>

··· From: Romain Vrignaud --- app/controllers/application_controller.rb | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 0783d91…4ce4944 100644
— a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -63,6 +63,17 @@ class ApplicationController < ActionController::Base
logger.warn(“Failed authentcation from #{request.remote_ip} #{user}”) if User.current.nil?
return !User.current.nil?
end

  • if login delegation authorized and REMOTE_USER not empty, authenticate user without using password

  • if SETTINGS[:authorize_login_delegation] == true and !request.env[“REMOTE_USER”].nil?
  • user = User.find_by_login(request.env["REMOTE_USER"])
    
  • User.current = user.is_a?(User) ? user : nil
    
  • if !user.nil? 
    
  •   session[:user] = User.current.id
    
  •   return !User.current.nil?
    
  • else 
    
  •   logger.warn("Failed authentcation from REMOTE_USER") if User.current.nil?
    
  • end
    
  • end
    session[:original_uri] = request.request_uri # keep the old request uri that we can redirect later on
    redirect_to login_users_path and return
    else

    1.7.2.5