2014-09-02 18:07:02 +05:30
|
|
|
module Gitlab
|
|
|
|
class Auth
|
|
|
|
def find(login, password)
|
2015-04-26 12:48:37 +05:30
|
|
|
user = User.by_login(login)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
# If no user is found, or it's an LDAP server, try LDAP.
|
|
|
|
# LDAP users are only authenticated via LDAP
|
2014-09-02 18:07:02 +05:30
|
|
|
if user.nil? || user.ldap_user?
|
|
|
|
# Second chance - try LDAP authentication
|
2015-04-26 12:48:37 +05:30
|
|
|
return nil unless Gitlab::LDAP::Config.enabled?
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
Gitlab::LDAP::Authentication.login(login, password)
|
2014-09-02 18:07:02 +05:30
|
|
|
else
|
|
|
|
user if user.valid_password?(password)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|