From 9651b4acbe99e870d955b3d74ae87f2abe9cd071 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 28 Oct 2016 14:34:19 +0200 Subject: [PATCH] rgw: inject token cache as a dependency in rgw::auth::keystone::TokenEngine. Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_auth_keystone.cc | 4 ++-- src/rgw/rgw_auth_keystone.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_auth_keystone.cc b/src/rgw/rgw_auth_keystone.cc index e80b4d93a97b1..d43d21d35b57d 100644 --- a/src/rgw/rgw_auth_keystone.cc +++ b/src/rgw/rgw_auth_keystone.cc @@ -225,7 +225,7 @@ TokenEngine::authenticate(const std::string& token) const ldout(cct, 20) << "token_id=" << token_id << dendl; /* Check cache first. */ - if (RGWKeystoneTokenCache::get_instance().find(token_id, t)) { + if (token_cache.find(token_id, t)) { ldout(cct, 20) << "cached token.project.id=" << t.get_project_id() << dendl; auto apl = apl_factory->create_apl_remote(cct, get_acl_strategy(t), @@ -260,7 +260,7 @@ TokenEngine::authenticate(const std::string& token) const ldout(cct, 0) << "validated token: " << t.get_project_name() << ":" << t.get_user_name() << " expires: " << t.get_expires() << dendl; - RGWKeystoneTokenCache::get_instance().add(token_id, t); + token_cache.add(token_id, t); auto apl = apl_factory->create_apl_remote(cct, get_acl_strategy(t), get_creds_info(t, roles.admin)); return std::make_pair(std::move(apl), nullptr); diff --git a/src/rgw/rgw_auth_keystone.h b/src/rgw/rgw_auth_keystone.h index 8d6ea25799f62..895942c8db1c5 100644 --- a/src/rgw/rgw_auth_keystone.h +++ b/src/rgw/rgw_auth_keystone.h @@ -28,6 +28,7 @@ class TokenEngine : public rgw::auth::Engine { const rgw::auth::TokenExtractor* const extractor; const rgw::auth::RemoteApplier::Factory* const apl_factory; rgw::keystone::Config& config; + rgw::keystone::TokenCache& token_cache; /* Helper methods. */ bool is_applicable(const std::string& token) const noexcept; @@ -43,11 +44,13 @@ public: TokenEngine(CephContext* const cct, const rgw::auth::TokenExtractor* const extractor, const rgw::auth::RemoteApplier::Factory* const apl_factory, - rgw::keystone::Config& config) + rgw::keystone::Config& config, + rgw::keystone::TokenCache& token_cache) : cct(cct), extractor(extractor), apl_factory(apl_factory), - config(config) { + config(config), + token_cache(token_cache) { } const char* get_name() const noexcept override { -- 2.39.5