From: Radoslaw Zarzynski Date: Thu, 26 Jan 2017 17:49:00 +0000 (+0100) Subject: rgw: the Swift's auth strategy is instantiated and injected from rgw_main.cc. X-Git-Tag: v12.0.2~305^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0134241b63d0f4773b384d740cfaf169f361e555;p=ceph.git rgw: the Swift's auth strategy is instantiated and injected from rgw_main.cc. Signed-off-by: Radoslaw Zarzynski Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 2a400ec4fb30..733d45670037 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -385,7 +385,11 @@ int main(int argc, const char **argv) } if (apis_map.count("swift") > 0) { - RGWRESTMgr_SWIFT* const swift_resource = new RGWRESTMgr_SWIFT; + static const rgw::auth::swift::DefaultStrategy auth_strategy(g_ceph_context, + store); + + RGWRESTMgr_SWIFT* const swift_resource = new RGWRESTMgr_SWIFT( + &auth_strategy); if (! g_conf->rgw_cross_domain_policy.empty()) { swift_resource->register_resource("crossdomain.xml", @@ -396,7 +400,7 @@ int main(int argc, const char **argv) set_logging(new RGWRESTMgr_SWIFT_HealthCheck)); swift_resource->register_resource("info", - set_logging(new RGWRESTMgr_SWIFT_Info)); + set_logging(new RGWRESTMgr_SWIFT_Info(&auth_strategy))); if (! swift_at_root) { rest.register_resource(g_conf->rgw_swift_url_prefix, diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 99ab54653c09..f692693d79a7 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -2463,14 +2463,14 @@ RGWHandler_REST* RGWRESTMgr_SWIFT::get_handler(struct req_state* const s, } if (s->init_state.url_bucket.empty()) { - return new RGWHandler_REST_Service_SWIFT; + return new RGWHandler_REST_Service_SWIFT(auth_strategy); } if (s->object.empty()) { - return new RGWHandler_REST_Bucket_SWIFT; + return new RGWHandler_REST_Bucket_SWIFT(auth_strategy); } - return new RGWHandler_REST_Obj_SWIFT; + return new RGWHandler_REST_Obj_SWIFT(auth_strategy); } RGWHandler_REST* RGWRESTMgr_SWIFT_Info::get_handler( @@ -2478,5 +2478,5 @@ RGWHandler_REST* RGWRESTMgr_SWIFT_Info::get_handler( const std::string& frontend_prefix) { s->prot_flags |= RGW_REST_SWIFT; - return new RGWHandler_REST_SWIFT_Info; + return new RGWHandler_REST_SWIFT_Info(auth_strategy); } diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index c5c5e335965c..a28fc2836c02 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -258,6 +258,8 @@ class RGWHandler_REST_SWIFT : public RGWHandler_REST { friend class RGWRESTMgr_SWIFT; friend class RGWRESTMgr_SWIFT_Info; protected: + const rgw::auth::Strategy& auth_strategy; + virtual bool is_acl_op() { return false; } @@ -265,8 +267,10 @@ protected: static int init_from_header(struct req_state* s, const std::string& frontend_prefix); public: - RGWHandler_REST_SWIFT() {} - ~RGWHandler_REST_SWIFT() override {} + RGWHandler_REST_SWIFT(const rgw::auth::Strategy& auth_strategy) + : auth_strategy(auth_strategy) { + } + ~RGWHandler_REST_SWIFT() override = default; static int validate_bucket_name(const string& bucket); @@ -274,7 +278,7 @@ public: int authorize() override; int postauth_init() override; - RGWAccessControlPolicy *alloc_policy() { return NULL; /* return new RGWAccessControlPolicy_SWIFT; */ } + RGWAccessControlPolicy *alloc_policy() { return nullptr; /* return new RGWAccessControlPolicy_SWIFT; */ } void free_policy(RGWAccessControlPolicy *policy) { delete policy; } }; @@ -285,8 +289,8 @@ protected: RGWOp *op_post() override; RGWOp *op_delete() override; public: - RGWHandler_REST_Service_SWIFT() {} - ~RGWHandler_REST_Service_SWIFT() override {} + using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; + ~RGWHandler_REST_Service_SWIFT() override = default; }; class RGWHandler_REST_Bucket_SWIFT : public RGWHandler_REST_SWIFT { @@ -306,8 +310,8 @@ protected: RGWOp *op_post() override; RGWOp *op_options() override; public: - RGWHandler_REST_Bucket_SWIFT() {} - ~RGWHandler_REST_Bucket_SWIFT() override {} + using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; + ~RGWHandler_REST_Bucket_SWIFT() override = default; int error_handler(int err_no, std::string *error_content) override { return website_handler->error_handler(err_no, error_content); @@ -344,8 +348,8 @@ protected: RGWOp *op_options() override; public: - RGWHandler_REST_Obj_SWIFT() {} - ~RGWHandler_REST_Obj_SWIFT() override {} + using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; + ~RGWHandler_REST_Obj_SWIFT() override = default; int error_handler(int err_no, std::string *error_content) override { return website_handler->error_handler(err_no, error_content); @@ -364,6 +368,8 @@ public: }; class RGWRESTMgr_SWIFT : public RGWRESTMgr { + const rgw::auth::Strategy& auth_strategy; + protected: RGWRESTMgr* get_resource_mgr_as_default(struct req_state* const s, const std::string& uri, @@ -372,7 +378,9 @@ protected: } public: - RGWRESTMgr_SWIFT() = default; + RGWRESTMgr_SWIFT(const rgw::auth::Strategy* const auth_strategy) + : auth_strategy(*auth_strategy) { + } ~RGWRESTMgr_SWIFT() override = default; RGWHandler_REST *get_handler(struct req_state *s, @@ -510,7 +518,10 @@ public: class RGWHandler_REST_SWIFT_Info : public RGWHandler_REST_SWIFT { public: - RGWHandler_REST_SWIFT_Info() = default; + //using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; + RGWHandler_REST_SWIFT_Info(const rgw::auth::Strategy& auth_strategy) + : RGWHandler_REST_SWIFT(auth_strategy) { + } ~RGWHandler_REST_SWIFT_Info() override = default; RGWOp *op_get() override { @@ -541,8 +552,12 @@ public: }; class RGWRESTMgr_SWIFT_Info : public RGWRESTMgr { + const rgw::auth::Strategy& auth_strategy; + public: - RGWRESTMgr_SWIFT_Info() = default; + RGWRESTMgr_SWIFT_Info(const rgw::auth::Strategy* const auth_strategy) + : auth_strategy(*auth_strategy) { + } ~RGWRESTMgr_SWIFT_Info() override = default; RGWHandler_REST *get_handler(struct req_state* s,