]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: inject token cache as a dependency in rgw::auth::keystone::TokenEngine.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 28 Oct 2016 12:34:19 +0000 (14:34 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 24 Mar 2017 15:54:32 +0000 (16:54 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth_keystone.cc
src/rgw/rgw_auth_keystone.h

index e80b4d93a97b1c1ed7a7a9429316e6456a0da158..d43d21d35b57d0994ba91d8e917c2aa9650c52e5 100644 (file)
@@ -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);
index 8d6ea25799f62ef51094ed127f41e3f54ab5716c..895942c8db1c571825b11ec4fcd75a0c10bdaedf 100644 (file)
@@ -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 {