Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-23 18:03:01 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-23 18:24:47 +0300
commit795cd7f95206db318c58939698f63eee5abedb34 (patch)
treef8e244b3ea6b80acb64b724b0aef04af3b5c4fa8
parentd3a8a07423dccf1709b6432e017ae4679143dbce (diff)
Replace define_method with alias_method in Omniauth Controllers
-rw-r--r--app/controllers/ldap/omniauth_callbacks_controller.rb14
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb12
-rw-r--r--lib/gitlab/auth/ldap/user.rb2
3 files changed, 12 insertions, 16 deletions
diff --git a/app/controllers/ldap/omniauth_callbacks_controller.rb b/app/controllers/ldap/omniauth_callbacks_controller.rb
index e9219274182..fb24edb8602 100644
--- a/app/controllers/ldap/omniauth_callbacks_controller.rb
+++ b/app/controllers/ldap/omniauth_callbacks_controller.rb
@@ -2,23 +2,21 @@ 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
+ return unless Gitlab::Auth::LDAP::Config.enabled?
+
+ Gitlab::Auth::LDAP::Config.available_servers.each do |server|
+ alias_method server['provider_name'], :ldap
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
+ define_providers!
+
override :set_remember_me
def set_remember_me(user)
user.remember_me = params[:remember_me] if user.persisted?
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index f7e7f04384a..9137bc92810 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -4,10 +4,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
protect_from_forgery except: [:kerberos, :saml, :cas3]
+ def handle_omniauth
+ omniauth_flow(Gitlab::Auth::OAuth)
+ end
+
Gitlab.config.omniauth.providers.each do |provider|
- define_method provider['name'] do
- handle_omniauth
- end
+ alias_method provider['name'], :handle_omniauth
end
# Extend the standard implementation to also increment
@@ -70,10 +72,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
private
- def handle_omniauth
- omniauth_flow(Gitlab::Auth::OAuth)
- end
-
def omniauth_flow(auth_module, identity_linker: nil)
if current_user
log_audit_event(current_user, with: oauth['provider'])
diff --git a/lib/gitlab/auth/ldap/user.rb b/lib/gitlab/auth/ldap/user.rb
index 604c2d222e9..6487f32f7b6 100644
--- a/lib/gitlab/auth/ldap/user.rb
+++ b/lib/gitlab/auth/ldap/user.rb
@@ -49,7 +49,7 @@ module Gitlab
end
def valid_sign_in?
- allowed?
+ allowed? && super
end
def ldap_config