Skip to content

Instantly share code, notes, and snippets.

@theanalyst
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theanalyst/c9a81e33d27f8a9bafbc to your computer and use it in GitHub Desktop.
Save theanalyst/c9a81e33d27f8a9bafbc to your computer and use it in GitHub Desktop.
import hmac
from hashlib import sha1
from time import time
method = 'GET'
duration_in_seconds = 60*60*24
expires = int(time() + duration_in_seconds)
path = '/v1/dsgasg/ceph.conf' # replace with bucket and object name
key = 'secret'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
sig = hmac.new(key, hmac_body, sha1).hexdigest()
s = 'http://{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}'
url = s.format(host='127.0.0.1:8080/swift', path=path, sig=sig, expires=expires)
print url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment