Make bcrypt + passlib work in password_hash filter

If hashtype for the password_hash filter is 'blowfish' and passlib is
available, hashing fails as the hash function for this is named 'bcrypt'
(and not 'blowfish_crypt').  Special case this so that the correct
function is called.
This commit is contained in:
Matt Robinson 2016-10-18 19:50:45 +01:00 committed by Michael Scherer
parent 843de98bad
commit 692bfa872a

View file

@ -257,7 +257,11 @@ def get_encrypted_password(password, hashtype='sha512', salt=None):
saltstring = "$%s$%s" % (cryptmethod[hashtype],salt)
encrypted = crypt.crypt(password, saltstring)
else:
cls = getattr(passlib.hash, '%s_crypt' % hashtype)
if hashtype == 'blowfish':
cls = passlib.hash.bcrypt;
else:
cls = getattr(passlib.hash, '%s_crypt' % hashtype)
encrypted = cls.encrypt(password, salt=salt)
return encrypted