]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: naturalize the transplanted get_keystone_{url,admin_token} in KeystoneService.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 7 Apr 2016 10:34:32 +0000 (12:34 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Jun 2016 13:12:11 +0000 (15:12 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_keystone.cc
src/rgw/rgw_keystone.h

index da35cb18c1ec25f6c9dc342fe4d07a84fcbb763d..431c53a209ce8b7f817a33c9202dce324952a9fd 100644 (file)
@@ -152,25 +152,24 @@ KeystoneApiVersion KeystoneService::get_api_version()
   }
 }
 
-int RGWSwift::get_keystone_url(CephContext * const cct,
-                               std::string& url)
+int KeystoneService::get_keystone_url(CephContext * const cct,
+                                      std::string& url)
 {
-  // FIXME: it seems we don't need RGWGetRevokedToken here
-  bufferlist bl;
-  RGWGetRevokedTokens req(cct, &bl);
-
   url = cct->_conf->rgw_keystone_url;
   if (url.empty()) {
     ldout(cct, 0) << "ERROR: keystone url is not configured" << dendl;
     return -EINVAL;
   }
-  if (url[url.size() - 1] != '/')
+
+  if (url[url.size() - 1] != '/') {
     url.append("/");
+  }
+
   return 0;
 }
 
-int RGWSwift::get_keystone_admin_token(CephContext * const cct,
-                                       std::string& token)
+int KeystoneService::get_keystone_admin_token(CephContext * const cct,
+                                              std::string& token)
 {
   std::string token_url;
 
index 10e8dd0ef937e5a413d44978c33c5be6e81338c9..63501ffa6d959961a315fc1686d85e991e3c40d4 100644 (file)
@@ -26,8 +26,35 @@ enum class KeystoneApiVersion {
 };
 
 class KeystoneService {
+  class RGWKeystoneHTTPTransceiver : public RGWHTTPTransceiver {
+  public:
+    RGWKeystoneHTTPTransceiver(CephContext * const cct,
+                               bufferlist * const token_body_bl)
+      : RGWHTTPTransceiver(cct, token_body_bl,
+                           cct->_conf->rgw_keystone_verify_ssl,
+                           { "X-Subject-Token" }) {
+    }
+
+    std::string get_subject_token() const {
+      try {
+        return get_header_value("X-Subject-Token");
+      } catch (std::out_of_range&) {
+        return header_value_t();
+      }
+    }
+  };
+
+  typedef RGWKeystoneHTTPTransceiver RGWValidateKeystoneToken;
+  typedef RGWKeystoneHTTPTransceiver RGWGetKeystoneAdminToken;
+  typedef RGWKeystoneHTTPTransceiver RGWGetRevokedTokens;
+
 public:
   static KeystoneApiVersion get_api_version();
+
+  static int get_keystone_url(CephContext * const cct,
+                              std::string& url);
+  static int get_keystone_admin_token(CephContext * const cct,
+                                      std::string& token);
 };
 
 class KeystoneToken {