2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-04-13 04:11:31 +00:00

Fix remote passphrase authentication

For python 3 platforms, the
db hosted hash
needed the str changed
to bytes explictly.
This commit is contained in:
Jarrod Johnson
2020-09-02 08:54:29 -04:00
parent b9fffad1f8
commit 46396247bb

View File

@@ -221,11 +221,11 @@ def check_user_passphrase(name, passphrase, operation=None, element=None, tenant
if ucfg is None:
eventlet.sleep(0.05)
return None
if isinstance(passphrase, bytes):
bpassphrase = passphrase
else:
bpassphrase = passphrase.encode('utf8')
if (user, tenant) in _passcache:
if isinstance(passphrase, bytes):
bpassphrase = passphrase
else:
bpassphrase = passphrase.encode('utf8')
if hashlib.sha256(bpassphrase).digest() == _passcache[(user, tenant)]:
return authorize(user, element, tenant, operation=operation)
else:
@@ -260,7 +260,7 @@ def check_user_passphrase(name, passphrase, operation=None, element=None, tenant
# determine failure because there is a delay, valid response will
# delay as well
if crypt == crypted:
_passcache[(user, tenant)] = hashlib.sha256(passphrase).digest()
_passcache[(user, tenant)] = hashlib.sha256(bpassphrase).digest()
return authorize(user, element, tenant, operation)
if pam:
pwe = None
@@ -291,10 +291,6 @@ def check_user_passphrase(name, passphrase, operation=None, element=None, tenant
# user
usergood = pam.authenticate(user, passphrase, service=_pamservice)
if usergood:
if isinstance(passphrase, bytes):
bpassphrase = passphrase
else:
bpassphrase = passphrase.encode('utf8')
_passcache[(user, tenant)] = hashlib.sha256(bpassphrase).digest()
return authorize(user, element, tenant, operation, skipuserobj=False)
eventlet.sleep(0.05) # stall even on test for existence of a username