2012-09-12 06:23:16 +00:00
|
|
|
module Gitlab
|
|
|
|
class Auth
|
2013-07-16 08:28:19 +00:00
|
|
|
def find(login, password)
|
2014-10-22 15:29:26 +00:00
|
|
|
user = User.by_login(login)
|
2013-07-16 08:28:19 +00:00
|
|
|
|
2014-10-13 15:24:05 +00:00
|
|
|
# If no user is found, or it's an LDAP server, try LDAP.
|
|
|
|
# LDAP users are only authenticated via LDAP
|
2013-07-16 08:28:19 +00:00
|
|
|
if user.nil? || user.ldap_user?
|
|
|
|
# Second chance - try LDAP authentication
|
2014-10-13 15:24:05 +00:00
|
|
|
return nil unless Gitlab::LDAP::Config.enabled?
|
2013-07-16 08:28:19 +00:00
|
|
|
|
2014-10-13 15:24:05 +00:00
|
|
|
Gitlab::LDAP::Authentication.login(login, password)
|
2013-07-16 08:28:19 +00:00
|
|
|
else
|
|
|
|
user if user.valid_password?(password)
|
|
|
|
end
|
|
|
|
end
|
2012-09-12 06:23:16 +00:00
|
|
|
end
|
|
|
|
end
|