-
-
Save theanalyst/c9a81e33d27f8a9bafbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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