]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: implement missing handlers for aws4 signatures
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 15 Jan 2016 00:04:41 +0000 (16:04 -0800)
committerJavier M. Mellid <jmunhoz@igalia.com>
Sat, 13 Feb 2016 12:51:39 +0000 (12:51 +0000)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h
src/rgw/rgw_rest_metadata.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h

index dc8f65007a5c538cc5c0721db293ed220b1eeb68..a7f306ee806bdc619239beebf44106bc124aaa23 100644 (file)
@@ -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;
index e79315f4306d98889ff73c04d40b4afc464879db..c3342cfccad23455dec933073ce0132ceae536bb 100644 (file)
@@ -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 {
index f97fdb4a722667b2211cceb248e6113098492a48..3cbb7d77a6dc3a9ee49e21d2201719ee66378aa6 100644 (file)
@@ -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);
   
index 079a6493f1b4be3aef7b45570de0c25d6f73ac13..ff03d24054bb7e9d5dcec8b8eae76b7dce40fff8 100644 (file)
@@ -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;
index 9fd63b447da17dfcc8d25ba9b57a55b4a1d575e2..5417de8d7041ead7ec9e12b7da5a4bba45e63369 100644 (file)
@@ -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,