From: Yehuda Sadeh Date: Fri, 15 Jan 2016 00:04:41 +0000 (-0800) Subject: rgw: implement missing handlers for aws4 signatures X-Git-Tag: v10.1.0~351^2^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b052b0d26982eb80414047b12020e5e3f513bbf1;p=ceph.git rgw: implement missing handlers for aws4 signatures Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index dc8f65007a5c..a7f306ee806b 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -1015,7 +1015,7 @@ int RGWPutACLs_ObjStore::get_params() return op_ret; } int read_len; - int r = s->cio->read(data, cl, &read_len); + int r = s->cio->read(data, cl, &read_len, s->aws4_auth_needs_complete); len = read_len; if (r < 0) return r; @@ -1039,7 +1039,7 @@ static int read_all_chunked_input(req_state *s, char **pdata, int *plen, int max int read_len = 0, len = 0; do { - int r = s->cio->read(data + len, need_to_read, &read_len); + int r = s->cio->read(data + len, need_to_read, &read_len, s->aws4_auth_needs_complete); if (r < 0) { free(data); return r; @@ -1092,7 +1092,7 @@ int rgw_rest_read_all_input(struct req_state *s, char **pdata, int *plen, int ma if (!data) { return -ENOMEM; } - int ret = s->cio->read(data, cl, &len); + int ret = s->cio->read(data, cl, &len, s->aws4_auth_needs_complete); if (ret < 0) { free(data); return ret; @@ -1198,7 +1198,7 @@ int RGWDeleteMultiObj_ObjStore::get_params() return op_ret; } int read_len; - op_ret = s->cio->read(data, cl, &read_len); + op_ret = s->cio->read(data, cl, &read_len, s->aws4_auth_needs_complete); len = read_len; if (op_ret < 0) return op_ret; diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index e79315f4306d..c3342cfccad2 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -283,7 +283,7 @@ public: RGWCompleteMultipart_ObjStore() {} ~RGWCompleteMultipart_ObjStore() {} - int get_params(); + virtual int get_params(); }; class RGWAbortMultipart_ObjStore : public RGWAbortMultipart { @@ -319,7 +319,7 @@ public: RGWDeleteMultiObj_ObjStore() {} ~RGWDeleteMultiObj_ObjStore() {} - int get_params(); + virtual int get_params(); }; class RGWRESTOp : public RGWOp { diff --git a/src/rgw/rgw_rest_metadata.cc b/src/rgw/rgw_rest_metadata.cc index f97fdb4a7226..3cbb7d77a6dc 100644 --- a/src/rgw/rgw_rest_metadata.cc +++ b/src/rgw/rgw_rest_metadata.cc @@ -157,6 +157,13 @@ void RGWOp_Metadata_Put::execute() { if (http_ret < 0) { return; } + + if (s->aws4_auth_needs_complete) { + http_ret = do_aws4_auth_completion(); + if (http_ret < 0) { + return; + } + } frame_metadata_key(s, metadata_key); diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 079a6493f1b4..ff03d24054bb 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -509,6 +509,13 @@ int RGWSetBucketVersioning_ObjStore_S3::get_params() return r; } + if (s->aws4_auth_needs_complete) { + int ret_auth = do_aws4_auth_completion(); + if (ret_auth < 0) { + return ret_auth; + } + } + RGWSetBucketVersioningParser parser; if (!parser.init()) { @@ -712,6 +719,13 @@ int RGWCreateBucket_ObjStore_S3::get_params() if ((op_ret < 0) && (op_ret != -ERR_LENGTH_REQUIRED)) return op_ret; + if (s->aws4_auth_needs_complete) { + int ret_auth = do_aws4_auth_completion(); + if (ret_auth < 0) { + return ret_auth; + } + } + bufferptr in_ptr(data, len); in_data.append(in_ptr); @@ -819,8 +833,9 @@ int RGWPutObj_ObjStore_S3::get_data(bufferlist& bl) s->aws4_auth_needs_complete = false; if ((ret == 0) && s->aws4_auth_needs_complete) { int ret_auth = do_aws4_auth_completion(); - if (ret_auth) + if (ret_auth < 0) { return ret_auth; + } } return ret; } @@ -1720,8 +1735,9 @@ int RGWPutACLs_ObjStore_S3::get_params() s->aws4_auth_needs_complete = false; if (s->aws4_auth_needs_complete) { int ret_auth = do_aws4_auth_completion(); - if (ret_auth) + if (ret_auth < 0) { return ret_auth; + } } return ret; } @@ -1794,7 +1810,7 @@ int RGWPutCORS_ObjStore_S3::get_params() goto done_err; } int read_len; - r = s->cio->read(data, cl, &read_len); + r = s->cio->read(data, cl, &read_len, s->aws4_auth_needs_complete); len = read_len; if (r < 0) goto done_err; @@ -1803,6 +1819,13 @@ int RGWPutCORS_ObjStore_S3::get_params() len = 0; } + if (s->aws4_auth_needs_complete) { + int ret_auth = do_aws4_auth_completion(); + if (ret_auth < 0) { + return ret_auth; + } + } + if (!parser.init()) { r = -EINVAL; goto done_err; @@ -1994,6 +2017,22 @@ void RGWInitMultipart_ObjStore_S3::send_response() } } +int RGWCompleteMultipart_ObjStore_S3::get_params() +{ + int ret = RGWCompleteMultipart_ObjStore::get_params(); + if (ret < 0) { + return ret; + } + + if (s->aws4_auth_needs_complete) { + int ret_auth = do_aws4_auth_completion(); + if (ret_auth < 0) { + return ret_auth; + } + } + return 0; +} + void RGWCompleteMultipart_ObjStore_S3::send_response() { if (op_ret) @@ -2157,6 +2196,22 @@ void RGWListBucketMultiparts_ObjStore_S3::send_response() rgw_flush_formatter_and_reset(s, s->formatter); } +int RGWDeleteMultiObj_ObjStore_S3::get_params() +{ + int ret = RGWDeleteMultiObj_ObjStore::get_params(); + if (ret < 0) { + return ret; + } + + if (s->aws4_auth_needs_complete) { + int ret_auth = do_aws4_auth_completion(); + if (ret_auth < 0) { + return ret_auth; + } + } + return 0; +} + void RGWDeleteMultiObj_ObjStore_S3::send_status() { if (! status_dumped) { @@ -3121,13 +3176,14 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s) switch (s->op_type) { + case RGW_OP_CREATE_BUCKET: case RGW_OP_PUT_OBJ: case RGW_OP_PUT_ACLS: - /* ops requiring aws4 completion but not implemented yet */ - //case RGW_OP_PUT_CORS: - //case RGW_OP_COMPLETE_MULTIPART: - //case RGW_OP_SET_BUCKET_VERSIONING: - //case RGW_OP_DELETE_MULTI_OBJ: + case RGW_OP_PUT_CORS: + case RGW_OP_COMPLETE_MULTIPART: + case RGW_OP_SET_BUCKET_VERSIONING: + case RGW_OP_DELETE_MULTI_OBJ: + case RGW_OP_ADMIN_SET_METADATA: break; default: dout(10) << "ERROR: AWS4 completion for this operation NOT IMPLEMENTED" << dendl; diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 9fd63b447da1..5417de8d7041 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -293,6 +293,7 @@ public: RGWCompleteMultipart_ObjStore_S3() {} ~RGWCompleteMultipart_ObjStore_S3() {} + int get_params(); void send_response(); }; @@ -327,6 +328,7 @@ public: RGWDeleteMultiObj_ObjStore_S3() {} ~RGWDeleteMultiObj_ObjStore_S3() {} + int get_params(); void send_status(); void begin_response(); void send_partial_response(rgw_obj_key& key, bool delete_marker,