check whether bcrypt is usuable with passlib/libpass version
This commit is contained in:
@@ -61,7 +61,7 @@ from typing import Any, Tuple
|
||||
|
||||
from passlib.hash import apr_md5_crypt, sha256_crypt, sha512_crypt
|
||||
|
||||
from radicale import auth, config, logger
|
||||
from radicale import auth, config, logger, utils
|
||||
|
||||
|
||||
class Auth(auth.BaseAuth):
|
||||
@@ -120,12 +120,22 @@ class Auth(auth.BaseAuth):
|
||||
"The htpasswd encryption method 'bcrypt' or 'autodetect' requires "
|
||||
"the bcrypt module (entries found: %d)." % self._htpasswd_bcrypt_use) from e
|
||||
else:
|
||||
self._has_bcrypt = True
|
||||
[bcrypt_usable, info] = utils.passlib_libpass_supports_bcrypt()
|
||||
if bcrypt_usable:
|
||||
self._has_bcrypt = True
|
||||
logger.debug(info)
|
||||
else:
|
||||
logger.warning(info)
|
||||
if self._encryption == "autodetect":
|
||||
if self._htpasswd_bcrypt_use == 0:
|
||||
logger.info("auth htpasswd encryption is 'radicale.auth.htpasswd_encryption.%s' and bcrypt module found, but currently not required", self._encryption)
|
||||
else:
|
||||
logger.info("auth htpasswd encryption is 'radicale.auth.htpasswd_encryption.%s' and bcrypt module found (bcrypt entries found: %d)", self._encryption, self._htpasswd_bcrypt_use)
|
||||
if not bcrypt_usable:
|
||||
raise RuntimeError("The htpasswd encryption 'autodetect' requires the bcrypt module but not usuable")
|
||||
else:
|
||||
if not bcrypt_usable:
|
||||
raise RuntimeError("The htpasswd encryption method 'bcrypt' requires the bcrypt module but not usuable")
|
||||
if self._encryption == "bcrypt":
|
||||
self._verify = functools.partial(self._bcrypt, bcrypt)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user