注意
本文档适用于 Ceph 开发版本。
临时URL操作
为了允许临时访问(例如对于请求)对象,而无需共享凭证,radosgw的swift端点支持临时URL功能。为此功能,最初应设置X-Account-Meta-Temp-URL-Key的值。可选地,应设置X-Account-Meta-Temp-URL-Key-2。GET requests) to objects without the need to share credentials, temp url functionality is supported by swift endpoint of radosgw. For this functionality, initially the value of X-Account-Meta-Temp-URL-Key and optionally 临时URL功能依赖于针对这些密钥的HMAC-SHA1签名。如果您计划为Swift API公开临时URL功能,强烈建议在端点定义中包含Swift账户名称,以便最接近原生OpenStack Swift的行为。为此,请设置c56624:配置选项,并将您的Keystone端点更新为URL后缀98a89f:。
Note
If you are planning to expose Temp URL functionality for the
Swift API, it is strongly recommended to include the Swift
account name in the endpoint definition, so as to most
closely emulate the behavior of native OpenStack Swift. To
do so, set the ceph.conf
configuration option rgw
swift account in url = true
, and update your Keystone
endpoint to the URL suffix /v1/AUTH_%(tenant_id)s
(而不是仅/v1
).
POST临时URL密钥
A POST
将带有所需密钥的请求发送到Swift账户将设置账户的密钥临时URL密钥,从而可以提供临时URL访问。最多支持两个密钥,如果存在,则对两个密钥进行签名检查,以便在不使临时URL失效的情况下旋转密钥。
Note
原生OpenStack Swift还支持在容器级别设置临时URL密钥的选项,通过针对容器发出0c96fc:请求来设置4b2753:。此功能在radosgw中不受支持;临时URL密钥只能设置和用于账户级别。POST
或PUT
request against a container that sets
X-Container-Meta-Temp-URL-Key
或X-Container-Meta-Temp-URL-Key-2
. This functionality is
not supported in radosgw; temporary URL keys can only be set
and used at the account level.
语法
POST /{api version}/{account} HTTP/1.1
Host: {fqdn}
X-Auth-Token: {auth-token}
请求头
X-Account-Meta-Temp-URL-Key
- 描述:
一个用户定义的键,它接受任意字符串值。
- 类型:
字符串
- 必需:
是
X-Account-Meta-Temp-URL-Key-2
- 描述:
一个用户定义的键,它接受任意字符串值。
- 类型:
字符串
- 必需:
否
GET临时URL对象
临时URL使用加密HMAC-SHA1签名,包括以下元素:
请求方法的值,“GET”例如
过期时间,以自纪元以来的秒数格式表示,即Unix时间
从“v1”开始的请求路径
上述项目使用新行追加规范化,并使用SHA-1哈希算法针对之前发布的临时URL密钥之一生成HMAC。
以下是一个示例Python脚本,用于演示上述内容:
import hmac
from hashlib import sha1
from time import time
method = 'GET'
host = 'https://objectstore.example.com/swift'
duration_in_seconds = 300 # Duration for which the url is valid
expires = int(time() + duration_in_seconds)
path = '/v1/your-bucket/your-object'
key = 'secret'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
sig = hmac.new(key, hmac_body, sha1).hexdigest()
rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
host=host, path=path, sig=sig, expires=expires)
print(rest_uri)
# Example Output
# https://objectstore.example.com/swift/v1/your-bucket/your-object?temp_url_sig=ff4657876227fc6025f04fcf1e82818266d022c6&temp_url_expires=1423200992
由 Ceph 基金会带给您
Ceph 文档是一个社区资源,由非盈利的 Ceph 基金会资助和托管Ceph Foundation. 如果您想支持这一点和我们的其他工作,请考虑加入现在加入.