mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
rgw: add optional tenant name for swift urls
In order to maintain compatibility with swift clients that expect the url to also contain a reference to the tenant name, add an optional param (empty by default) that would add it. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
2626101f17
commit
0e43ac903d
@ -684,6 +684,7 @@ OPTION(rgw_swift_url, OPT_STR, "") // the swift url, being published
|
||||
OPTION(rgw_swift_url_prefix, OPT_STR, "swift") // entry point for which a url is considered a swift url
|
||||
OPTION(rgw_swift_auth_url, OPT_STR, "") // default URL to go and verify tokens for v1 auth (if not using internal swift auth)
|
||||
OPTION(rgw_swift_auth_entry, OPT_STR, "auth") // entry point for which a url is considered a swift auth url
|
||||
OPTION(rgw_swift_tenant_name, OPT_STR, "") // tenant name to use for swift access
|
||||
OPTION(rgw_keystone_url, OPT_STR, "") // url for keystone server
|
||||
OPTION(rgw_keystone_admin_token, OPT_STR, "") // keystone admin token (shared secret)
|
||||
OPTION(rgw_keystone_admin_user, OPT_STR, "") // keystone admin user name
|
||||
|
@ -848,9 +848,15 @@ int RGWHandler_ObjStore_SWIFT::init_from_header(struct req_state *s)
|
||||
first = req;
|
||||
}
|
||||
|
||||
string tenant_path;
|
||||
if (!g_conf->rgw_swift_tenant_name.empty()) {
|
||||
tenant_path = "/AUTH_";
|
||||
tenant_path.append(g_conf->rgw_swift_tenant_name);
|
||||
}
|
||||
|
||||
/* verify that the request_uri conforms with what's expected */
|
||||
char buf[g_conf->rgw_swift_url_prefix.length() + 16];
|
||||
int blen = sprintf(buf, "/%s/v1", g_conf->rgw_swift_url_prefix.c_str());
|
||||
char buf[g_conf->rgw_swift_url_prefix.length() + 16 + tenant_path.length()];
|
||||
int blen = sprintf(buf, "/%s/v1%s", g_conf->rgw_swift_url_prefix.c_str(), tenant_path.c_str());
|
||||
if (s->decoded_uri[0] != '/' ||
|
||||
s->decoded_uri.compare(0, blen, buf) != 0) {
|
||||
return -ENOENT;
|
||||
|
@ -142,6 +142,7 @@ void RGW_SWIFT_Auth_Get::execute()
|
||||
|
||||
string swift_url = g_conf->rgw_swift_url;
|
||||
string swift_prefix = g_conf->rgw_swift_url_prefix;
|
||||
string tenant_path;
|
||||
|
||||
if (swift_prefix.size() == 0) {
|
||||
swift_prefix = DEFAULT_SWIFT_PREFIX;
|
||||
@ -199,8 +200,13 @@ void RGW_SWIFT_Auth_Get::execute()
|
||||
goto done;
|
||||
}
|
||||
|
||||
s->cio->print("X-Storage-Url: %s/%s/v1\n", swift_url.c_str(),
|
||||
swift_prefix.c_str());
|
||||
if (!g_conf->rgw_swift_tenant_name.empty()) {
|
||||
tenant_path = "/AUTH_";
|
||||
tenant_path.append(g_conf->rgw_swift_tenant_name);
|
||||
}
|
||||
|
||||
s->cio->print("X-Storage-Url: %s/%s/v1%s\n", swift_url.c_str(),
|
||||
swift_prefix.c_str(), tenant_path.c_str());
|
||||
|
||||
if ((ret = encode_token(s->cct, swift_key->id, swift_key->key, bl)) < 0)
|
||||
goto done;
|
||||
|
Loading…
Reference in New Issue
Block a user