]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: Code to make S3 and STS co-exist in same namespace.
authorPritha Srivastava <prsrivas@redhat.com>
Wed, 8 Aug 2018 09:40:51 +0000 (15:10 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Fri, 21 Sep 2018 05:39:33 +0000 (11:09 +0530)
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/CMakeLists.txt
src/rgw/rgw_main.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h

index 8efd43bd63d96b64c5c161769c994dc31a3ac08f..a7abc8bc8ec3f3a5aacd0b0ffb4c7f75e8a9cf44 100644 (file)
@@ -108,7 +108,10 @@ set(librgw_common_srcs
   rgw_crypt.cc
   rgw_crypt_sanitize.cc
   rgw_iam_policy.cc
-  rgw_rest_user_policy.cc)
+  rgw_rest_user_policy.cc
+  rgw_sts.cc
+  rgw_rest_sts.cc)
+
 add_library(rgw_common OBJECT ${librgw_common_srcs})
 
 if(WITH_LTTNG)
index abbeaade68f82113f968a5b2c2a9ab62d5c9dca3..82f9708ebf88c6fecfc2f69ac4571da7503aab4d 100644 (file)
@@ -341,12 +341,13 @@ int main(int argc, const char **argv)
 
   // S3 website mode is a specialization of S3
   const bool s3website_enabled = apis_map.count("s3website") > 0;
+  const bool sts_enabled = apis_map.count("sts") > 0;
   // Swift API entrypoint could placed in the root instead of S3
   const bool swift_at_root = g_conf()->rgw_swift_url_prefix == "/";
   if (apis_map.count("s3") > 0 || s3website_enabled) {
     if (! swift_at_root) {
       rest.register_default_mgr(set_logging(rest_filter(store, RGW_REST_S3,
-                                                        new RGWRESTMgr_S3(s3website_enabled))));
+                                                        new RGWRESTMgr_S3(s3website_enabled, sts_enabled))));
     } else {
       derr << "Cannot have the S3 or S3 Website enabled together with "
            << "Swift API placed in the root of hierarchy" << dendl;
@@ -402,11 +403,6 @@ int main(int argc, const char **argv)
     rest.register_resource(g_conf()->rgw_admin_entry, admin_resource);
   }
 
-  if (apis_map.count("sts") > 0) {
-    auto *sts = new RGWRESTMgr_STS;
-    rest.register_resource(g_conf()->rgw_sts_entry, set_logging(sts));
-  }
-
   /* Initialize the registry of auth strategies which will coordinate
    * the dynamic reconfiguration. */
   auto auth_registry = \
index f9ec11c0325977775e5b782f25500958f2615b2e..e80cc3ff17cf2dea996f343ff2bf0d020bf9092c 100644 (file)
@@ -48,6 +48,7 @@
 #include "include/ceph_assert.h"
 #include "include/assert.h"
 #include "rgw_role.h"
+#include "rgw_rest_sts.h"
 #include "rgw_sts.h"
 
 #define dout_context g_ceph_context
@@ -3026,6 +3027,11 @@ RGWOp *RGWHandler_REST_Service_S3::op_post()
     if (action.compare("DeleteUserPolicy") == 0)
       return new RGWDeleteUserPolicy;
   }
+  if (this->isSTSenabled) {
+    RGWHandler_REST_STS sts_handler(auth_registry);
+    sts_handler.init(store, s, s->cio);
+    return sts_handler.get_op(store);
+  }
   return NULL;
 }
 
@@ -3522,7 +3528,7 @@ RGWHandler_REST* RGWRESTMgr_S3::get_handler(struct req_state* const s,
     }
   } else {
     if (s->init_state.url_bucket.empty()) {
-      handler = new RGWHandler_REST_Service_S3(auth_registry);
+      handler = new RGWHandler_REST_Service_S3(auth_registry, enable_sts);
     } else if (s->object.empty()) {
       handler = new RGWHandler_REST_Bucket_S3(auth_registry);
     } else {
index 97181b291857e8d48c75ed5b5e42aecd2e314cc5..f535ad82fb10243841bcd04261deddad1b4d642e 100644 (file)
@@ -499,7 +499,7 @@ public:
 
 class RGWHandler_REST_S3 : public RGWHandler_REST {
   friend class RGWRESTMgr_S3;
-
+protected:
   const rgw::auth::StrategyRegistry& auth_registry;
 public:
   static int init_from_header(struct req_state *s, int default_formatter, bool configurable_format);
@@ -521,6 +521,7 @@ public:
 
 class RGWHandler_REST_Service_S3 : public RGWHandler_REST_S3 {
 protected:
+    bool isSTSenabled;
     bool is_usage_op() {
     return s->info.args.exists("usage");
   }
@@ -528,7 +529,9 @@ protected:
   RGWOp *op_head() override;
   RGWOp *op_post() override;
 public:
-  using RGWHandler_REST_S3::RGWHandler_REST_S3;
+   RGWHandler_REST_Service_S3(const rgw::auth::StrategyRegistry& auth_registry,
+                              bool isSTSenabled) :
+      RGWHandler_REST_S3(auth_registry), isSTSenabled(isSTSenabled) {}
   ~RGWHandler_REST_Service_S3() override = default;
 };
 
@@ -592,9 +595,11 @@ public:
 class RGWRESTMgr_S3 : public RGWRESTMgr {
 private:
   bool enable_s3website;
+  bool enable_sts;
 public:
-  explicit RGWRESTMgr_S3(bool enable_s3website = false)
-    : enable_s3website(enable_s3website) {
+  explicit RGWRESTMgr_S3(bool enable_s3website = false, bool enable_sts = false)
+    : enable_s3website(enable_s3website),
+      enable_sts(enable_sts) {
   }
 
   ~RGWRESTMgr_S3() override = default;