From 71abf70458ca1f6d85bc828b215931eaf3639b5d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Sep 2013 23:50:45 +0300 Subject: Move ldap auth to LDAP::User. Removed unused code --- lib/gitlab/auth.rb | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'lib/gitlab/auth.rb') diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 5f4b6c22c2c..34e25bc9ccb 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -66,23 +66,12 @@ module Gitlab Gitlab::AppLogger end - def ldap_auth(login, password) - # Check user against LDAP backend if user is not authenticated - # Only check with valid login and password to prevent anonymous bind results - return nil unless ldap_conf.enabled && !login.blank? && !password.blank? - - ldap = OmniAuth::LDAP::Adaptor.new(ldap_conf) - ldap_user = ldap.bind_as( - filter: Net::LDAP::Filter.eq(ldap.uid, login), - size: 1, - password: password - ) - - User.find_by_extern_uid_and_provider(ldap_user.dn, 'ldap') if ldap_user - end - def ldap_conf @ldap_conf ||= Gitlab.config.ldap end + + def ldap_auth(login, password) + Gitlab::LDAP::User.auth(login, password) + end end end -- cgit v1.2.1