2018-09-23 15:44:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-18 10:03:27 -04:00
|
|
|
class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
|
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
|
|
|
def self.define_providers!
|
2018-04-23 11:03:01 -04:00
|
|
|
return unless Gitlab::Auth::LDAP::Config.enabled?
|
|
|
|
|
|
|
|
Gitlab::Auth::LDAP::Config.available_servers.each do |server|
|
|
|
|
alias_method server['provider_name'], :ldap
|
2018-04-18 10:03:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# We only find ourselves here
|
|
|
|
# if the authentication to LDAP was successful.
|
|
|
|
def ldap
|
|
|
|
sign_in_user_flow(Gitlab::Auth::LDAP::User)
|
|
|
|
end
|
|
|
|
|
2018-04-23 11:03:01 -04:00
|
|
|
define_providers!
|
|
|
|
|
2018-04-18 10:03:27 -04:00
|
|
|
override :set_remember_me
|
|
|
|
def set_remember_me(user)
|
|
|
|
user.remember_me = params[:remember_me] if user.persisted?
|
|
|
|
end
|
|
|
|
|
|
|
|
override :fail_login
|
|
|
|
def fail_login(user)
|
2019-04-16 06:32:05 -04:00
|
|
|
flash[:alert] = _('Access denied for your LDAP account.')
|
2018-04-18 10:03:27 -04:00
|
|
|
|
|
|
|
redirect_to new_user_session_path
|
|
|
|
end
|
|
|
|
end
|