From 36285143cec0e73b8930d10b19b9326a101fc16c Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 12 Mar 2024 07:38:40 +0100 Subject: [PATCH] fix for incomplete https://github.com/Kozea/Radicale/pull/1425 and test --- radicale/auth/htpasswd.py | 4 ++++ radicale/tests/test_auth.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/radicale/auth/htpasswd.py b/radicale/auth/htpasswd.py index 098f7b783..3bdffacae 100644 --- a/radicale/auth/htpasswd.py +++ b/radicale/auth/htpasswd.py @@ -74,6 +74,10 @@ def __init__(self, configuration: config.Configuration) -> None: self._verify = self._plain elif encryption == "md5": self._verify = self._md5apr1 + elif encryption == "sha256": + self._verify = self._sha256 + elif encryption == "sha512": + self._verify = self._sha512 elif encryption == "bcrypt" or encryption == "autodetect": try: import bcrypt diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index f33780b6e..089059fcf 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -82,6 +82,12 @@ def test_htpasswd_md5_unicode(self): self._test_htpasswd( "md5", "😀:$apr1$w4ev89r1$29xO8EvJmS2HEAadQ5qy11", "unicode") + def test_htpasswd_sha256(self) -> None: + self._test_htpasswd("sha256", "tmp:$5$i4Ni4TQq6L5FKss5$ilpTjkmnxkwZeV35GB9cYSsDXTALBn6KtWRJAzNlCL/") + + def test_htpasswd_sha512(self) -> None: + self._test_htpasswd("sha512", "tmp:$6$3Qhl8r6FLagYdHYa$UCH9yXCed4A.J9FQsFPYAOXImzZUMfvLa0lwcWOxWYLOF5sE/lF99auQ4jKvHY2vijxmefl7G6kMqZ8JPdhIJ/") + def test_htpasswd_bcrypt(self) -> None: self._test_htpasswd("bcrypt", "tmp:$2y$05$oD7hbiQFQlvCM7zoalo/T.MssV3V" "NTRI3w5KDnj8NTUKJNWfVpvRq")