5 To allow temporary access (for eg for `GET` requests) to objects
6 without the need to share credentials, temp url functionality is
7 supported by swift endpoint of radosgw. For this functionality,
8 initially the value of `X-Account-Meta-Temp-URL-Key` and optionally
9 `X-Account-Meta-Temp-URL-Key-2` should be set. The Temp URL
10 functionality relies on a HMAC-SHA1 signature against these secret
16 A ``POST`` request to the swift account with the required Key will set
17 the secret temp url key for the account against which temporary url
18 access can be provided to accounts. Up to two keys are supported, and
19 signatures are checked against both the keys, if present, so that keys
20 can be rotated without invalidating the temporary urls.
27 POST /{api version}/{account} HTTP/1.1
29 X-Auth-Token: {auth-token}
34 ``X-Account-Meta-Temp-URL-Key``
36 :Description: A user-defined key that takes an arbitrary string value.
40 ``X-Account-Meta-Temp-URL-Key-2``
42 :Description: A user-defined key that takes an arbitrary string value.
50 Temporary URL uses a cryptographic HMAC-SHA1 signature, which includes
51 the following elements:
53 #. The value of the Request method, "GET" for instance
54 #. The expiry time, in format of seconds since the epoch, ie Unix time
55 #. The request path starting from "v1" onwards
57 The above items are normalized with newlines appended between them,
58 and a HMAC is generated using the SHA-1 hashing algorithm against one
59 of the Temp URL Keys posted earlier.
61 A sample python script to demonstrate the above is given below:
64 .. code-block:: python
67 from hashlib import sha1
71 host = 'https://objectstore.example.com/swift'
72 duration_in_seconds = 300 # Duration for which the url is valid
73 expires = int(time() + duration_in_seconds)
74 path = '/v1/your-bucket/your-object'
76 hmac_body = '%s\n%s\n%s' % (method, expires, path)
77 sig = hmac.new(key, hmac_body, sha1).hexdigest()
78 rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
79 host=host, path=path, sig=sig, expires=expires)
83 # https://objectstore.example.com/swift/v1/your-bucket/your-object?temp_url_sig=ff4657876227fc6025f04fcf1e82818266d022c6&temp_url_expires=1423200992