summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-07-22 13:33:33 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-07-22 14:46:25 -0700
commitf0843c1322660c772499e26b46dbb4fc2f0d9bd3 (patch)
treec4c7d657af67d950789210a2136833ab73511076
parenteabf2f6ae1ec244092315b79efe5b886c2b18578 (diff)
downloadceph-f0843c1322660c772499e26b46dbb4fc2f0d9bd3.tar.gz
rgw: translate swift request to s3 when forwarding
When forwarding a swift request to a different region, we need to use the effective uri, and not just send the one we got since we use S3 authentication for the forwarded requests. This is achieved through a new using 'effective_uri' param on the request info (which in swift ponts to the plain bucket/object uri without the swift/v1 prefix(. Also, rename the old req_state::effective_uri to relative_uri in order to prevent confusion. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_auth_s3.cc8
-rw-r--r--src/rgw/rgw_common.cc7
-rw-r--r--src/rgw/rgw_common.h3
-rw-r--r--src/rgw/rgw_rest.cc2
-rw-r--r--src/rgw/rgw_rest_client.cc2
-rw-r--r--src/rgw/rgw_rest_s3.cc2
-rw-r--r--src/rgw/rgw_rest_swift.cc5
7 files changed, 24 insertions, 5 deletions
diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc
index bdd458e68b6..c93de7cd58a 100644
--- a/src/rgw/rgw_auth_s3.cc
+++ b/src/rgw/rgw_auth_s3.cc
@@ -190,8 +190,14 @@ bool rgw_create_s3_canonical_header(req_info& info, utime_t *header_time, string
map<string, string>& meta_map = info.x_meta_map;
map<string, string>& sub_resources = info.args.get_sub_resources();
+ string request_uri;
+ if (info.effective_uri.empty())
+ request_uri = info.request_uri;
+ else
+ request_uri = info.effective_uri;
+
rgw_create_s3_canonical_header(info.method, content_md5, content_type, date.c_str(),
- meta_map, info.request_uri.c_str(), sub_resources,
+ meta_map, request_uri.c_str(), sub_resources,
dest);
return true;
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc
index aea396bf3de..8a281775d07 100644
--- a/src/rgw/rgw_common.cc
+++ b/src/rgw/rgw_common.cc
@@ -109,7 +109,12 @@ void req_info::rebuild_from(req_info& src)
{
method = src.method;
script_uri = src.script_uri;
- request_uri = src.request_uri;
+ if (src.effective_uri.empty()) {
+ request_uri = src.request_uri;
+ } else {
+ request_uri = src.effective_uri;
+ }
+ effective_uri.clear();
host = src.host;
x_meta_map = src.x_meta_map;
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index 1d3596d4418..7f224a798f5 100644
--- a/src/rgw/rgw_common.h
+++ b/src/rgw/rgw_common.h
@@ -764,6 +764,7 @@ struct req_info {
const char *method;
string script_uri;
string request_uri;
+ string effective_uri;
string request_params;
req_info(CephContext *cct, RGWEnv *_env);
@@ -780,7 +781,7 @@ struct req_state {
int format;
ceph::Formatter *formatter;
string decoded_uri;
- string effective_uri;
+ string relative_uri;
const char *length;
uint64_t content_length;
map<string, string> generic_attrs;
diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc
index 0f9e61d1740..e4933a67a39 100644
--- a/src/rgw/rgw_rest.cc
+++ b/src/rgw/rgw_rest.cc
@@ -1242,7 +1242,7 @@ RGWHandler *RGWREST::get_handler(RGWRados *store, struct req_state *s, RGWClient
if (*init_error < 0)
return NULL;
- RGWRESTMgr *m = mgr.get_resource_mgr(s, s->decoded_uri, &s->effective_uri);
+ RGWRESTMgr *m = mgr.get_resource_mgr(s, s->decoded_uri, &s->relative_uri);
if (!m) {
*init_error = -ERR_METHOD_NOT_ALLOWED;
return NULL;
diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc
index 2075e535525..ea80b5b84f8 100644
--- a/src/rgw/rgw_rest_client.cc
+++ b/src/rgw/rgw_rest_client.cc
@@ -403,6 +403,7 @@ int RGWRESTStreamWriteRequest::put_obj_init(RGWAccessKey& key, rgw_obj& obj, uin
new_info.script_uri = "/";
new_info.script_uri.append(resource);
new_info.request_uri = new_info.script_uri;
+ new_info.effective_uri = new_info.effective_uri;
map<string, string>& m = new_env.get_map();
map<string, bufferlist>::iterator bliter;
@@ -568,6 +569,7 @@ int RGWRESTStreamReadRequest::get_obj(RGWAccessKey& key, map<string, string>& ex
new_info.script_uri = "/";
new_info.script_uri.append(resource);
new_info.request_uri = new_info.script_uri;
+ new_info.effective_uri = new_info.effective_uri;
new_info.init_meta_info(NULL);
diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc
index 66f6652ec6a..b0e37719c8b 100644
--- a/src/rgw/rgw_rest_s3.cc
+++ b/src/rgw/rgw_rest_s3.cc
@@ -1801,7 +1801,7 @@ int RGWHandler_ObjStore_S3::init_from_header(struct req_state *s, int default_fo
string req;
string first;
- const char *req_name = s->effective_uri.c_str();
+ const char *req_name = s->relative_uri.c_str();
const char *p;
if (*req_name == '?') {
diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc
index 157158e7ed7..ff237862b1d 100644
--- a/src/rgw/rgw_rest_swift.cc
+++ b/src/rgw/rgw_rest_swift.cc
@@ -829,11 +829,16 @@ int RGWHandler_ObjStore_SWIFT::init_from_header(struct req_state *s)
s->bucket_name_str = first;
s->bucket_name = strdup(s->bucket_name_str.c_str());
+
+ s->info.effective_uri = "/" + s->bucket_name_str;
+
if (req.size()) {
s->object_str = req;
s->object = strdup(s->object_str.c_str());
+ s->info.effective_uri.append("/" + s->object_str);
}
+
return 0;
}