]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: implement rgw::auth::AnonymousEngine.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 13 Dec 2016 14:27:31 +0000 (15:27 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 24 Mar 2017 15:54:33 +0000 (16:54 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth.cc
src/rgw/rgw_auth.h

index f60cb95771536262e9f8cf56d8a22886da68994b..879eb3c015c49115cde98bd6821b4df410876a47 100644 (file)
@@ -738,3 +738,20 @@ void rgw::auth::LocalApplier::load_acct_info(RGWUserInfo& user_info) const /* ou
    * to RADOS may be safely skipped in this case. */
   user_info = this->user_info;
 }
+
+
+rgw::auth::Engine::result_t
+rgw::auth::AnonymousEngine::authenticate(const req_state* const s) const
+{
+  if (! is_applicable()) {
+    return std::make_pair(nullptr, nullptr);
+  } else {
+    RGWUserInfo user_info;
+    rgw_get_anon_user(user_info);
+
+    // FIXME: over 80 columns
+    auto apl = apl_factory->create_apl_local(cct, user_info,
+                                             rgw::auth::LocalApplier::NO_SUBUSER);
+    return std::make_pair(std::move(apl), nullptr);
+  }
+}
index cf1a2343adb9b3cc63eb205b2cf8e8eb0b598b72..1e2f0c12eab6a86bb120c52c925a4d1e4b3ed750 100644 (file)
@@ -690,6 +690,31 @@ public:
     };
 };
 
+
+/* The anonymous abstract engine. */
+class AnonymousEngine : public Engine {
+  CephContext* const cct;
+  const rgw::auth::LocalApplier::Factory* const apl_factory;
+
+public:
+  AnonymousEngine(CephContext* const cct,
+                  const rgw::auth::LocalApplier::Factory* const apl_factory)
+    : cct(cct),
+      apl_factory(apl_factory) {
+  }
+
+  const char* get_name() const noexcept override {
+    return "rgw::auth::AnonymousEngine";
+  }
+
+  Engine::result_t authenticate(const req_state* s) const override final;
+
+protected:
+  virtual bool is_applicable() const noexcept {
+    return true;
+  }
+};
+
 } /* namespace auth */
 } /* namespace rgw */