mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
fixes triggered by tox
This commit is contained in:
parent
30e2ab490e
commit
9af15e6656
2 changed files with 9 additions and 9 deletions
|
@ -96,7 +96,7 @@ class BaseAuth:
|
|||
h.update(salt.encode())
|
||||
h.update(login.encode())
|
||||
h.update(password.encode())
|
||||
return h.digest()
|
||||
return str(h.digest())
|
||||
|
||||
def get_external_login(self, environ: types.WSGIEnviron) -> Union[
|
||||
Tuple[()], Tuple[str, str]]:
|
||||
|
@ -155,8 +155,8 @@ class BaseAuth:
|
|||
digest = self._cache_digest(login, password, str(time_ns))
|
||||
if result == "":
|
||||
result = self._login(login, password)
|
||||
if result is not "":
|
||||
if digest is "":
|
||||
if result != "":
|
||||
if digest == "":
|
||||
# successful login, but expired, digest must be recalculated
|
||||
digest = self._cache_digest(login, password, str(time_ns))
|
||||
# store successful login in cache
|
||||
|
|
|
@ -94,23 +94,23 @@ class Auth(auth.BaseAuth):
|
|||
raise RuntimeError("The htpasswd encryption method %r is not "
|
||||
"supported." % encryption)
|
||||
|
||||
def _plain(self, hash_value: str, password: str) -> bool:
|
||||
def _plain(self, hash_value: str, password: str) -> tuple[str, bool]:
|
||||
"""Check if ``hash_value`` and ``password`` match, plain method."""
|
||||
return ("PLAIN", hmac.compare_digest(hash_value.encode(), password.encode()))
|
||||
|
||||
def _bcrypt(self, bcrypt: Any, hash_value: str, password: str) -> bool:
|
||||
def _bcrypt(self, bcrypt: Any, hash_value: str, password: str) -> tuple[str, bool]:
|
||||
return ("BCRYPT", bcrypt.checkpw(password=password.encode('utf-8'), hashed_password=hash_value.encode()))
|
||||
|
||||
def _md5apr1(self, hash_value: str, password: str) -> bool:
|
||||
def _md5apr1(self, hash_value: str, password: str) -> tuple[str, bool]:
|
||||
return ("MD5-APR1", apr_md5_crypt.verify(password, hash_value.strip()))
|
||||
|
||||
def _sha256(self, hash_value: str, password: str) -> bool:
|
||||
def _sha256(self, hash_value: str, password: str) -> tuple[str, bool]:
|
||||
return ("SHA-256", sha256_crypt.verify(password, hash_value.strip()))
|
||||
|
||||
def _sha512(self, hash_value: str, password: str) -> bool:
|
||||
def _sha512(self, hash_value: str, password: str) -> tuple[str, bool]:
|
||||
return ("SHA-512", sha512_crypt.verify(password, hash_value.strip()))
|
||||
|
||||
def _autodetect(self, hash_value: str, password: str) -> bool:
|
||||
def _autodetect(self, hash_value: str, password: str) -> tuple[str, bool]:
|
||||
if hash_value.startswith("$apr1$", 0, 6) and len(hash_value) == 37:
|
||||
# MD5-APR1
|
||||
return self._md5apr1(hash_value, password)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue