fix production LDAP routing

This commit is contained in:
Josh 2017-07-10 11:11:10 -04:00
parent a45f4d4fd0
commit 042622cb01

View File

@ -25,3 +25,30 @@ end
OmniAuth.config.on_failure = Proc.new { |env| OmniAuth.config.on_failure = Proc.new { |env|
OmniAuth::FailureEndpoint.new(env).redirect_to_failure OmniAuth::FailureEndpoint.new(env).redirect_to_failure
} }
# Work around beacuse callback_url option causes
# omniauth.auth to be nil in the authhash when
# authenticating with LDAP.
module OmniAuthLDAPExt
def request_phase
rel_root = ENV['RELATIVE_URL_ROOT'].present? ? ENV['RELATIVE_URL_ROOT'] : '/b'
rel_root = '' if Rails.env == 'development'
@callback_path = nil
path = options[:callback_path]
options[:callback_path] = "#{rel_root}/auth/ldap/callback"
form = super
options[:callback_path] = path
form
end
end
module OmniAuth
module Strategies
class LDAP
prepend OmniAuthLDAPExt
end
end
end