Skip to content

Commit 138b7b7

Browse files
committed
Fix bug when creating temporary URLs
Pythons HMAC does not accept unicode, therefore converting key and hmac body to string (to be compatible with Python 2.x). Python 3 needs a byte conversion. See also: http://bugs.python.org/issue5285
1 parent 6e87d72 commit 138b7b7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

swiftbrowser/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_temp_url(storage_url, auth_token, container, objectname, expires=600):
107107
path = "%s/%s/%s" % (url_parts.path, container, objectname)
108108
base = "%s://%s" % (url_parts.scheme, url_parts.netloc)
109109
hmac_body = 'GET\n%s\n%s' % (expires, path)
110-
sig = hmac.new(key, hmac_body.encode("utf-8"), sha1).hexdigest()
110+
sig = hmac.new(str(key), str(hmac_body.encode("utf-8")), sha1).hexdigest()
111111
url = '%s%s?temp_url_sig=%s&temp_url_expires=%s' % (
112112
base, path, sig, expires)
113113
return url

0 commit comments

Comments
 (0)