diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py --- a/kallithea/lib/auth.py +++ b/kallithea/lib/auth.py @@ -52,7 +52,7 @@ from kallithea.model.db import User, Rep 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 @@ class KallitheaCrypto(object): 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 @@ class KallitheaCrypto(object): 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__) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ if sys.version_info < (2, 7): requirements.append("argparse") if not is_windows: - requirements.append("py-bcrypt>=0.3.0,<=0.4") + requirements.append("bcrypt>=2.0.0") dependency_links = [