Commit a69977e7 authored by James Edwards-Jones's avatar James Edwards-Jones

Replace define_method with alias_method in Omniauth Controllers

parent a2235739
...@@ -4,23 +4,21 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController ...@@ -4,23 +4,21 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
prepend EE::Ldap::OmniauthCallbacksController prepend EE::Ldap::OmniauthCallbacksController
def self.define_providers! def self.define_providers!
if Gitlab::Auth::LDAP::Config.enabled? return unless Gitlab::Auth::LDAP::Config.enabled?
Gitlab::Auth::LDAP::Config.available_servers.each do |server|
define_method server['provider_name'] do Gitlab::Auth::LDAP::Config.available_servers.each do |server|
ldap alias_method server['provider_name'], :ldap
end
end
end end
end end
define_providers!
# We only find ourselves here # We only find ourselves here
# if the authentication to LDAP was successful. # if the authentication to LDAP was successful.
def ldap def ldap
sign_in_user_flow(Gitlab::Auth::LDAP::User) sign_in_user_flow(Gitlab::Auth::LDAP::User)
end end
define_providers!
override :set_remember_me override :set_remember_me
def set_remember_me(user) def set_remember_me(user)
user.remember_me = params[:remember_me] if user.persisted? user.remember_me = params[:remember_me] if user.persisted?
......
...@@ -5,10 +5,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -5,10 +5,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
protect_from_forgery except: [:kerberos, :saml, :cas3] protect_from_forgery except: [:kerberos, :saml, :cas3]
def handle_omniauth
omniauth_flow(Gitlab::Auth::OAuth)
end
Gitlab.config.omniauth.providers.each do |provider| Gitlab.config.omniauth.providers.each do |provider|
define_method provider['name'] do alias_method provider['name'], :handle_omniauth
handle_omniauth
end
end end
# Extend the standard implementation to also increment # Extend the standard implementation to also increment
...@@ -81,10 +83,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -81,10 +83,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
private private
def handle_omniauth
omniauth_flow(Gitlab::Auth::OAuth)
end
def omniauth_flow(auth_module, identity_linker: nil) def omniauth_flow(auth_module, identity_linker: nil)
if current_user if current_user
log_audit_event(current_user, with: oauth['provider']) log_audit_event(current_user, with: oauth['provider'])
......
...@@ -50,7 +50,7 @@ module Gitlab ...@@ -50,7 +50,7 @@ module Gitlab
end end
def valid_sign_in? def valid_sign_in?
allowed? allowed? && super
end end
def ldap_config def ldap_config
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment