diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-04-18 15:03:27 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-04-22 23:50:55 +0100 |
commit | f10c999bca2b5b37b068ff3680a6e35a6707828d (patch) | |
tree | a517f86544c1544ee25d174652a003fff9b199a0 /app/controllers/ldap | |
parent | c212908aad9b32352653dfe9ca966f148c8dfc1a (diff) | |
download | gitlab-ce-f10c999bca2b5b37b068ff3680a6e35a6707828d.tar.gz |
Refactor OmniauthCallbacksController to remove duplication
Moves LDAP to its own controller with tests
Provides path forward for implementing GroupSaml
Diffstat (limited to 'app/controllers/ldap')
-rw-r--r-- | app/controllers/ldap/omniauth_callbacks_controller.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/controllers/ldap/omniauth_callbacks_controller.rb b/app/controllers/ldap/omniauth_callbacks_controller.rb new file mode 100644 index 00000000000..e9219274182 --- /dev/null +++ b/app/controllers/ldap/omniauth_callbacks_controller.rb @@ -0,0 +1,33 @@ +class Ldap::OmniauthCallbacksController < OmniauthCallbacksController + extend ::Gitlab::Utils::Override + + def self.define_providers! + if Gitlab::Auth::LDAP::Config.enabled? + Gitlab::Auth::LDAP::Config.available_servers.each do |server| + define_method server['provider_name'] do + ldap + end + end + end + end + + define_providers! + + # We only find ourselves here + # if the authentication to LDAP was successful. + def ldap + sign_in_user_flow(Gitlab::Auth::LDAP::User) + end + + 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) + flash[:alert] = 'Access denied for your LDAP account.' + + redirect_to new_user_session_path + end +end |