From 9aa6d17db032f6a0b1803725ae4122f97e55b1ae Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 13 Dec 2016 15:27:31 +0100 Subject: [PATCH] rgw: implement rgw::auth::AnonymousEngine. Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_auth.cc | 17 +++++++++++++++++ src/rgw/rgw_auth.h | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index f60cb95771536..879eb3c015c49 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -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); + } +} diff --git a/src/rgw/rgw_auth.h b/src/rgw/rgw_auth.h index cf1a2343adb9b..1e2f0c12eab6a 100644 --- a/src/rgw/rgw_auth.h +++ b/src/rgw/rgw_auth.h @@ -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 */ -- 2.39.5