diff options
author | Tim Burke <tim.burke@gmail.com> | 2022-07-22 21:38:57 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2022-08-29 13:13:34 -0700 |
commit | f4e62191bc174e6235130aab36feb3b161de7848 (patch) | |
tree | 3103b0c5ba3a7a1567f8c11a1cfb6dc5e472abff /swiftclient | |
parent | 662e530d8d4e8e74ba087733f1f51cb98d5145cc (diff) | |
download | python-swiftclient-f4e62191bc174e6235130aab36feb3b161de7848.tar.gz |
Allow tempurl to be used to sign /info requests
Change-Id: I1f9d26541e9c8f5aec7a6790c87df397d178efe6
Diffstat (limited to 'swiftclient')
-rw-r--r-- | swiftclient/utils.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/swiftclient/utils.py b/swiftclient/utils.py index 1b80e6d..0a67537 100644 --- a/swiftclient/utils.py +++ b/swiftclient/utils.py @@ -173,7 +173,11 @@ def generate_temp_url(path, seconds, key, method, absolute=False, raise ValueError('digest must be one of sha1, sha256, or sha512') parts = path_for_body.split('/', 4) - if len(parts) != 5 or parts[0] or not all(parts[1:(4 if prefix else 5)]): + if path_for_body == '/info': + # /info signatures do not support prefixes or ip ranges + prefix = False + ip_range = None + elif len(parts) != 5 or parts[0] or not all(parts[1:(4 if prefix else 5)]): if prefix: raise ValueError('path must at least contain /v1/a/c/') else: @@ -220,8 +224,12 @@ def generate_temp_url(path, seconds, key, method, absolute=False, expiration = time.strftime( EXPIRES_ISO8601_FORMAT, time.gmtime(expiration)) - temp_url = '{path}?temp_url_sig={sig}&temp_url_expires={exp}'.format( - path=path_for_body, sig=sig, exp=expiration) + if path_for_body == '/info': + temp_url = '{path}?swiftinfo_sig={sig}&swiftinfo_expires={exp}'.format( + path=path_for_body, sig=sig, exp=expiration) + else: + temp_url = '{path}?temp_url_sig={sig}&temp_url_expires={exp}'.format( + path=path_for_body, sig=sig, exp=expiration) if ip_range: temp_url += '&temp_url_ip_range={}'.format(ip_range) |