Skip to content

Commit

Permalink
Fix encoding error with non-ascii passwords.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnouri committed Jun 7, 2012
1 parent 9bd0c76 commit 1fa5d28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,8 @@ Change History
0.7a3 - Unreleased
------------------

- Fix encoding error with non-ascii passwords.

0.7a2 - 2012-06-07
------------------

Expand Down
3 changes: 2 additions & 1 deletion kotti/security.py
Expand Up @@ -464,7 +464,8 @@ def search(self, **kwargs):
def hash_password(self, password, hashed=None):
if hashed is None:
hashed = bcrypt.gensalt(self.log_rounds)
return unicode(bcrypt.hashpw(password, hashed))
return unicode(
bcrypt.hashpw(password.encode('utf-8'), hashed.encode('utf-8')))

def validate_password(self, clear, hashed):
try:
Expand Down
3 changes: 3 additions & 0 deletions kotti/tests/test_security.py
Expand Up @@ -418,6 +418,9 @@ def _assert_is_bob(self, bob):
self.assertEqual(bob.title, u'Bob Dabolina')
self.assertEqual(bob.groups, [u'group:bobsgroup'])

def test_hash_password_non_ascii(self):
self.get_principals().hash_password(u'\xd6TEst')

def test_default_admin(self):
admin = self.get_principals()[u'admin']
self.assertTrue(
Expand Down

0 comments on commit 1fa5d28

Please sign in to comment.