From: Yehuda Sadeh Date: Tue, 26 Nov 2013 21:39:38 +0000 (-0800) Subject: rgw: add optional tenant name for swift urls X-Git-Tag: v0.78~333^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0e43ac903d25eaa06669cd84ce5fa7b5dc28b943;p=ceph.git 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 --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 0a452fec46bb..f6c704197e63 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index c958aa3a9e4d..daeb77601306 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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; diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index b42be89b740a..9c800c4c2c71 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -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;