Mercurial > kallithea
changeset 6000:023d9202481e
setup: use modern bcrypt implementation instead of unsupported old one
py-bcrypt has been deprecated by bcrypt, and is no longer developed
or supported.
bcrypt requires bytestrings instead of strings, use safe_str to ensure
they're encoded before they're passed to bcrypt. Also, use check_pw
to minimise the number of manual conversions and comparisons.
Installation of bcrypt will probably compile a C extension and require
libffi-dev.
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Sun, 03 Jul 2016 12:21:00 +0200 |
parents | 58809814b51d |
children | 23057179017f |
files | kallithea/lib/auth.py setup.py |
diffstat | 2 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/auth.py Tue Jun 14 21:23:51 2016 +0200 +++ b/kallithea/lib/auth.py Sun Jul 03 12:21:00 2016 +0200 @@ -52,7 +52,7 @@ RepoGroup, UserGroupRepoGroupToPerm, UserIpMap, UserGroupUserGroupToPerm, \ UserGroup, UserApiKeys -from kallithea.lib.utils2 import safe_unicode, aslist +from kallithea.lib.utils2 import safe_str, safe_unicode, aslist from kallithea.lib.utils import get_repo_slug, get_repo_group_slug, \ get_user_group_slug, conditional_cache from kallithea.lib.caching_query import FromCache @@ -107,7 +107,7 @@ return hashlib.sha256(str_).hexdigest() elif is_unix: import bcrypt - return bcrypt.hashpw(str_, bcrypt.gensalt(10)) + return bcrypt.hashpw(safe_str(str_), bcrypt.gensalt(10)) else: raise Exception('Unknown or unsupported platform %s' \ % __platform__) @@ -126,7 +126,7 @@ return hashlib.sha256(password).hexdigest() == hashed elif is_unix: import bcrypt - return bcrypt.hashpw(password, hashed) == hashed + return bcrypt.checkpw(safe_str(password), safe_str(hashed)) else: raise Exception('Unknown or unsupported platform %s' \ % __platform__)