diff options
author | Prashanth Pai <ppai@redhat.com> | 2016-03-08 15:28:42 +0530 |
---|---|---|
committer | Thiago da Silva <thiago@redhat.com> | 2016-03-15 06:05:41 -0700 |
commit | 5078be08017a21d97a3cf3fa2ffe554ad7f3d2c9 (patch) | |
tree | 21cdb24cd9c2fde4f8a8a5ff9d7d26682a2b3ae0 /gluster | |
parent | 9b42f6f85b076202055bb90820db3499cc6015e5 (diff) |
Don't pass unicode to hmac.new()
This issue can be hit when swift3 middleware is in the pipeline.
This change is a backport of the following swauth change:
https://review.openstack.org/#/c/282191/
Change-Id: I323d3eeaf39e2019f8f8910bc53904ac94208ed2
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Reviewed-on: http://review.gluster.org/13641
Reviewed-by: Thiago da Silva <thiago@redhat.com>
Tested-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'gluster')
-rw-r--r-- | gluster/swift/common/middleware/gswauth/swauth/middleware.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gluster/swift/common/middleware/gswauth/swauth/middleware.py b/gluster/swift/common/middleware/gswauth/swauth/middleware.py index 8581dd4..e181ece 100644 --- a/gluster/swift/common/middleware/gswauth/swauth/middleware.py +++ b/gluster/swift/common/middleware/gswauth/swauth/middleware.py @@ -320,6 +320,13 @@ class Swauth(object): password = detail['auth'].split(':')[-1] msg = base64.urlsafe_b64decode(unquote(token)) + + # https://bugs.python.org/issue5285 + if isinstance(password, unicode): + password = password.encode('utf-8') + if isinstance(msg, unicode): + msg = msg.encode('utf-8') + s = base64.encodestring(hmac.new(password, msg, sha1).digest()).strip() if s != sign: |