From 5078be08017a21d97a3cf3fa2ffe554ad7f3d2c9 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Tue, 8 Mar 2016 15:28:42 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/13641 Reviewed-by: Thiago da Silva Tested-by: Thiago da Silva --- gluster/swift/common/middleware/gswauth/swauth/middleware.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gluster') 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: -- cgit