debian-mirror-gitlab/app/controllers/ldap/omniauth_callbacks_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
extend ::Gitlab::Utils::Override
def self.define_providers!
2020-04-08 14:13:33 +05:30
return unless Gitlab::Auth::Ldap::Config.sign_in_enabled?
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
Gitlab::Auth::Ldap::Config.available_servers.each do |server|
2018-10-15 14:42:47 +05:30
alias_method server['provider_name'], :ldap
end
end
# We only find ourselves here
# if the authentication to LDAP was successful.
def ldap
2020-04-08 14:13:33 +05:30
return unless Gitlab::Auth::Ldap::Config.sign_in_enabled?
2019-12-26 22:10:19 +05:30
2021-04-29 21:17:54 +05:30
if Gitlab::CurrentSettings.admin_mode
2020-05-24 23:13:21 +05:30
return admin_mode_flow(Gitlab::Auth::Ldap::User) if current_user_mode.admin_mode_requested?
end
2020-04-08 14:13:33 +05:30
sign_in_user_flow(Gitlab::Auth::Ldap::User)
2018-10-15 14:42:47 +05:30
end
define_providers!
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-07-31 22:56:46 +05:30
flash[:alert] = _('Access denied for your LDAP account.')
2018-10-15 14:42:47 +05:30
redirect_to new_user_session_path
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Ldap::OmniauthCallbacksController.prepend_mod_with('Ldap::OmniauthCallbacksController')