From 9b4d1139d1c2482e16eec01af91b092769cc3ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 20 Apr 2023 13:31:55 +0200 Subject: [PATCH] Converted username to lowercase for internal db --- server/src/uds/auths/InternalDB/authenticator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/uds/auths/InternalDB/authenticator.py b/server/src/uds/auths/InternalDB/authenticator.py index e47726b58..d7929fe22 100644 --- a/server/src/uds/auths/InternalDB/authenticator.py +++ b/server/src/uds/auths/InternalDB/authenticator.py @@ -107,11 +107,12 @@ class InternalDBAuth(auths.Authenticator): def mfaIdentifier(self, username: str) -> str: try: - return self.dbAuthenticator().users.get(name=username, state=State.ACTIVE).mfa_data + return self.dbAuthenticator().users.get(name=username.lower(), state=State.ACTIVE).mfa_data except Exception: # User not found return '' def transformUsername(self, username: str) -> str: + username = username.lower() if self.differentForEachHost.isTrue(): newUsername = self.getIp() + '-' + username # Duplicate basic user into username. @@ -137,6 +138,7 @@ class InternalDBAuth(auths.Authenticator): def authenticate( self, username: str, credentials: str, groupsManager: 'auths.GroupsManager' ) -> bool: + username = username.lower() logger.debug('Username: %s, Password: %s', username, credentials) dbAuth = self.dbAuthenticator() try: @@ -158,7 +160,7 @@ class InternalDBAuth(auths.Authenticator): def getGroups(self, username: str, groupsManager: 'auths.GroupsManager'): dbAuth = self.dbAuthenticator() try: - user: 'models.User' = dbAuth.users.get(name=username, state=State.ACTIVE) + user: 'models.User' = dbAuth.users.get(name=username.lower(), state=State.ACTIVE) except Exception: return @@ -167,7 +169,7 @@ class InternalDBAuth(auths.Authenticator): def getRealName(self, username: str) -> str: # Return the real name of the user, if it is set try: - user = self.dbAuthenticator().users.get(name=username, state=State.ACTIVE) + user = self.dbAuthenticator().users.get(name=username.lower(), state=State.ACTIVE) return user.real_name or username except Exception: return super().getRealName(username)