]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: reuse the HTTP client of KeystoneService in RGWKeystoneAuthEngine.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 23 May 2016 20:37:28 +0000 (22:37 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Jun 2016 19:17:13 +0000 (21:17 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth.cc
src/rgw/rgw_keystone.h

index 9088fce7e23afa2a138fff0eb67e5375b6c65090..b5771021b80655e302920bd21935789171c1f2de 100644 (file)
@@ -269,29 +269,6 @@ RGWAuthApplier::aplptr_t RGWAnonymousAuthEngine::authenticate() const
 
 
 /* Keystone */
-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;
-
-
 bool RGWKeystoneAuthEngine::is_applicable() const noexcept
 {
   if (! RGWTokenBasedAuthEngine::is_applicable()) {
@@ -323,6 +300,8 @@ KeystoneToken RGWKeystoneAuthEngine::decode_pki_token(const std::string& token)
 
 KeystoneToken RGWKeystoneAuthEngine::get_from_keystone(const std::string& token) const
 {
+  using RGWValidateKeystoneToken = KeystoneService::RGWValidateKeystoneToken;
+
   bufferlist token_body_bl;
   RGWValidateKeystoneToken validate(cct, &token_body_bl);
 
index e2a3bfa80ba32080f60a27e164653601afd1e6d9..d83542ccb6e2fa284697e38526c45b4fbe647244 100644 (file)
@@ -33,6 +33,7 @@ enum class KeystoneApiVersion {
 };
 
 class KeystoneService {
+public:
   class RGWKeystoneHTTPTransceiver : public RGWHTTPTransceiver {
   public:
     RGWKeystoneHTTPTransceiver(CephContext * const cct,
@@ -42,11 +43,12 @@ class KeystoneService {
                            { "X-Subject-Token" }) {
     }
 
-    std::string get_subject_token() const {
+    const header_value_t& get_subject_token() const {
       try {
         return get_header_value("X-Subject-Token");
       } catch (std::out_of_range&) {
-        return header_value_t();
+        static header_value_t empty_val;
+        return empty_val;
       }
     }
   };
@@ -55,7 +57,6 @@ class KeystoneService {
   typedef RGWKeystoneHTTPTransceiver RGWGetKeystoneAdminToken;
   typedef RGWKeystoneHTTPTransceiver RGWGetRevokedTokens;
 
-public:
   static KeystoneApiVersion get_api_version();
 
   static int get_keystone_url(CephContext * const cct,