#36226: Only PBKDF2PasswordHasher supports str and bytes password
------------------------------+------------------------------------
Reporter: Jason Held | Owner: (none)
Type: Bug | Status: new
Component: contrib.auth | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Sarah Boyce):
* stage: Unreviewed => Accepted
Comment:
Replicated thank you! PRs welcome
{{{#!diff
--- a/tests/auth_tests/test_hashers.py
+++ b/tests/auth_tests/test_hashers.py
@@ -520,6 +520,19 @@ class TestUtilsHashPass(SimpleTestCase):
with self.assertRaisesMessage(ValueError, msg):
hasher.encode("password", salt)
+ def test_password_bytes(self):
+ hasher_classes = [
+ MD5PasswordHasher,
+ PBKDF2PasswordHasher,
+ PBKDF2SHA1PasswordHasher,
+ ScryptPasswordHasher,
+ ]
+ for hasher_class in hasher_classes:
+ hasher = hasher_class()
+ with self.subTest(hasher_class.__name__):
+ encoded = hasher.encode(b"password", hasher.salt())
+ self.assertTrue(hasher.verify(b"password", encoded))
+
def test_encode_password_required(self):
hasher_classes = [
MD5PasswordHasher,
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/36226#comment:1>