diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-08 21:44:20 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-08 21:44:20 +0000 |
| commit | d1c2e857771c3c2c2ec2be173b91152150bb522e (patch) | |
| tree | 00f1becff0b9ffb69473869b69c8315914d1f3c2 /keystone | |
| parent | e968acee4be4c5ea006fd4326711bafe7f7e0c86 (diff) | |
| parent | 95280608fc82f7ae51f8c42678d6a7f0ac2ecff0 (diff) | |
Merge "Cope with unicode passwords or None" into redux
Diffstat (limited to 'keystone')
| -rw-r--r-- | keystone/common/utils.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/keystone/common/utils.py b/keystone/common/utils.py index 16692bd6..6997eddd 100644 --- a/keystone/common/utils.py +++ b/keystone/common/utils.py @@ -2,7 +2,7 @@ # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. -# Copyright 2011 Justin Santa Barbara +# Copyright 2011 - 2012 Justin Santa Barbara # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -144,7 +144,8 @@ class Ec2Signer(object): def hash_password(password): """Hash a password. Hard.""" salt = bcrypt.gensalt(CONF.bcrypt_strength) - return bcrypt.hashpw(password, salt) + password_utf8 = password.encode('utf-8') + return bcrypt.hashpw(password_utf8, salt) def check_password(password, hashed): @@ -155,7 +156,10 @@ def check_password(password, hashed): of that password (mostly). Neat! """ - check = bcrypt.hashpw(password, hashed[:29]) + if password is None: + return False + password_utf8 = password.encode('utf-8') + check = bcrypt.hashpw(password_utf8, hashed[:29]) return check == hashed |
