using password validation in login only for saving cpu time (fake sleep by invalid passwords instead of make hash calculation with argon2)

This commit is contained in:
einhornimmond 2021-03-04 18:00:19 +01:00 committed by Ulf Gebhardt
parent d6b59d5dfd
commit 32a2b4d851
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD

View File

@ -736,6 +736,8 @@ UserState Session::loadUser(const std::string& email, const std::string& passwor
{
static const char* functionName = "Session::loadUser";
auto observer = SingletonTaskObserver::getInstance();
auto sm = SessionManager::getInstance();
if (email != "") {
if (observer->getTaskCount(email, TASK_OBSERVER_PASSWORD_CREATION) > 0) {
return USER_PASSWORD_ENCRYPTION_IN_PROCESS;
@ -765,6 +767,14 @@ UserState Session::loadUser(const std::string& email, const std::string& passwor
return USER_DISABLED;
}
if (mNewUser->getUserState() >= USER_LOADED_FROM_DB) {
NotificationList pwd_errors;
if (!sm->checkPwdValidation(password, &pwd_errors))
{
Poco::Thread::sleep(ServerConfig::g_FakeLoginSleepTime);
return USER_PASSWORD_INCORRECT;
}
int loginResult = mNewUser->login(password);
int exitCount = 0;
if (loginResult == -3)