From: Radoslaw Zarzynski Date: Mon, 23 May 2016 20:37:28 +0000 (+0200) Subject: rgw: reuse the HTTP client of KeystoneService in RGWKeystoneAuthEngine. X-Git-Tag: v11.0.0~283^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=649448d2b17b0f0aea24acd377bdc4a6631e7b27;p=ceph.git rgw: reuse the HTTP client of KeystoneService in RGWKeystoneAuthEngine. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index 9088fce7e23a..b5771021b806 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -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); diff --git a/src/rgw/rgw_keystone.h b/src/rgw/rgw_keystone.h index e2a3bfa80ba3..d83542ccb6e2 100644 --- a/src/rgw/rgw_keystone.h +++ b/src/rgw/rgw_keystone.h @@ -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,