M #-: Validate username before authentication

This commit is contained in:
Ruben S. Montero authored and GitHub committed 2020-05-26 17:00:14 +02:00
commit 24f12f6734
1 file changed
+7
+7
View File
@@ -1351,6 +1351,7 @@ bool UserPool::authenticate(const string& session,
User * user = 0;
string username;
string token;
string error_str;
int rc;
bool ar;
@@ -1362,6 +1363,12 @@ bool UserPool::authenticate(const string& session,
return false;
}
if (!PoolObjectSQL::name_is_valid(username, User::INVALID_NAME_CHARS, error_str))
{
NebulaLog::log("AuM",Log::ERROR, "User is invalid, " + error_str );
return false;
}
user = get(username);
if (user != 0 ) //User known to OpenNebula