Fix s3.core for py34
check_signature was failing with an error since hmac.new expects bytes for the key. Also, base64.encodestring is deprecated in favor of base64.encodebytes. bp python3 Change-Id: I36bcf0e020b98ffa0e34464fee22a949b872c08f
This commit is contained in:
parent
a9c794ae5e
commit
a977148c9f
@ -25,6 +25,8 @@ import base64
|
||||
import hashlib
|
||||
import hmac
|
||||
|
||||
import six
|
||||
|
||||
from keystone.common import extension
|
||||
from keystone.common import json_home
|
||||
from keystone.common import utils
|
||||
@ -66,9 +68,15 @@ class S3Extension(wsgi.V3ExtensionRouter):
|
||||
class S3Controller(controllers.Ec2Controller):
|
||||
def check_signature(self, creds_ref, credentials):
|
||||
msg = base64.urlsafe_b64decode(str(credentials['token']))
|
||||
key = str(creds_ref['secret'])
|
||||
signed = base64.encodestring(
|
||||
hmac.new(key, msg, hashlib.sha1).digest()).strip()
|
||||
key = str(creds_ref['secret']).encode('utf-8')
|
||||
|
||||
if six.PY2:
|
||||
b64_encode = base64.encodestring
|
||||
else:
|
||||
b64_encode = base64.encodebytes
|
||||
|
||||
signed = b64_encode(
|
||||
hmac.new(key, msg, hashlib.sha1).digest()).decode('utf-8').strip()
|
||||
|
||||
if not utils.auth_str_equal(credentials['signature'], signed):
|
||||
raise exception.Unauthorized('Credential signature mismatch')
|
||||
|
1
tox.ini
1
tox.ini
@ -28,6 +28,7 @@ commands =
|
||||
keystone/tests/unit/test_backend_endpoint_policy.py \
|
||||
keystone/tests/unit/test_backend_rules.py \
|
||||
keystone/tests/unit/test_cache_backend_mongo.py \
|
||||
keystone/tests/unit/test_contrib_s3_core.py \
|
||||
keystone/tests/unit/test_driver_hints.py \
|
||||
keystone/tests/unit/test_policy.py \
|
||||
keystone/tests/unit/test_singular_plural.py \
|
||||
|
Loading…
x
Reference in New Issue
Block a user