1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-10-31 22:47:05 +01:00

improve authentication log messages

Signed-off-by: Thomas Schmid <tom@binary-kitchen.de>
This commit is contained in:
Thomas 2019-03-06 22:28:25 +01:00 committed by Ralf Ramsauer
parent 5645ba22c9
commit 0511fac330

View File

@ -73,14 +73,18 @@ class Authenticator:
return self._backends return self._backends
def _try_auth_local(self, user, password): def _try_auth_local(self, user, password):
log.info(' Trying to local auth (user, password) as user %s',user)
if user not in self._local_db: if user not in self._local_db:
log.info(' No user %s in local database', user)
return DoorlockResponse.Perm return DoorlockResponse.Perm
stored_pw = self._local_db[user][0] stored_pw = self._local_db[user][0]
stored_salt = self._local_db[user][1] stored_salt = self._local_db[user][1]
if stored_pw == hashlib.sha256(stored_salt.encode() + password.encode()).hexdigest(): if stored_pw == hashlib.sha256(stored_salt.encode() + password.encode()).hexdigest():
log.info(' Authenticated as user %s', user)
return DoorlockResponse.Success return DoorlockResponse.Success
log.info(' Invalid credentials')
return DoorlockResponse.Perm return DoorlockResponse.Perm
def _try_auth_ldap(self, user, password): def _try_auth_ldap(self, user, password):
@ -96,6 +100,7 @@ class Authenticator:
except ldap.LDAPError as e: except ldap.LDAPError as e:
log.info(' LDAP Error: %s' % e) log.info(' LDAP Error: %s' % e)
return DoorlockResponse.InternalError return DoorlockResponse.InternalError
log.info(' Authenticated as user %s', user)
return DoorlockResponse.Success return DoorlockResponse.Success
def try_auth(self, credentials): def try_auth(self, credentials):