Commit 20a88f5c43efa3ab0af80d26c90268132e6f7997

Authored by Friedrich Beckmann
1 parent 228baa80

LDAP authentication in grack - check ldap conf before call / added comment

Showing 1 changed file with 6 additions and 2 deletions   Show diff stats
lib/gitlab/backend/grack_auth.rb
@@ -34,11 +34,15 @@ module Grack @@ -34,11 +34,15 @@ module Grack
34 login, password = @auth.credentials 34 login, password = @auth.credentials
35 self.user = User.find_by_email(login) || User.find_by_username(login) 35 self.user = User.find_by_email(login) || User.find_by_username(login)
36 36
37 - if user.nil? 37 + # If the provided login was not a known email or username
  38 + # then user is nil
  39 + if user.nil?
  40 + # Second chance - try LDAP authentication
  41 + return false unless Gitlab.config.ldap.enabled
38 ldap_auth(login,password) 42 ldap_auth(login,password)
39 return false unless !user.nil? 43 return false unless !user.nil?
40 else 44 else
41 - return false unless user.valid_password?(password); 45 + return false unless user.valid_password?(password)
42 end 46 end
43 47
44 Gitlab::ShellEnv.set_env(user) 48 Gitlab::ShellEnv.set_env(user)