gitlab-org--gitlab-foss/lib/gitlab/auth.rb

25 lines
519 B
Ruby
Raw Normal View History

2012-09-12 02:23:16 -04:00
module Gitlab
class Auth
2013-07-16 04:28:19 -04:00
def find(login, password)
2014-01-19 13:55:59 -05:00
user = User.find_by(email: login) || User.find_by(username: login)
2013-07-16 04:28:19 -04:00
if user.nil? || user.ldap_user?
# Second chance - try LDAP authentication
return nil unless ldap_conf.enabled
2013-09-03 17:12:00 -04:00
Gitlab::LDAP::User.authenticate(login, password)
2013-07-16 04:28:19 -04:00
else
user if user.valid_password?(password)
end
end
2012-09-12 02:23:16 -04:00
def log
Gitlab::AppLogger
end
2013-05-24 13:36:28 -04:00
def ldap_conf
@ldap_conf ||= Gitlab.config.ldap
end
2012-09-12 02:23:16 -04:00
end
end