Avoid resource intensive login checks if password is not provided

Fixes #32598
This commit is contained in:
Horatiu Eugen Vlad 2017-05-19 08:38:31 +00:00
parent b064229994
commit 9735ce15de
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
title: Avoid resource intensive login checks if password is not provided.
merge_request: 11537
author: Horatiu Eugen Vlad

View File

@ -37,6 +37,9 @@ module Gitlab
end
def find_with_user_password(login, password)
# Avoid resource intensive login checks if password is not provided
return unless password.present?
Gitlab::Auth::UniqueIpsLimiter.limit_user! do
user = User.by_login(login)
@ -44,7 +47,7 @@ module Gitlab
# LDAP users are only authenticated via LDAP
if user.nil? || user.ldap_user?
# Second chance - try LDAP authentication
return nil unless Gitlab::LDAP::Config.enabled?
return unless Gitlab::LDAP::Config.enabled?
Gitlab::LDAP::Authentication.login(login, password)
else