From: Kefu Chai Date: Tue, 9 Apr 2019 06:36:45 +0000 (+0800) Subject: crimson/mon: implement AuthServer methods X-Git-Tag: v15.1.0~2986^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f9e1e2499a44e3c05fdf5bfc304200cbde002f6;p=ceph.git crimson/mon: implement AuthServer methods Signed-off-by: Kefu Chai --- diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index d47bf04cf13f..0a6e1371b236 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -277,6 +277,7 @@ Client::Client(ceph::net::Messenger& messenger, CEPH_ENTITY_TYPE_MGR}, timer{[this] { tick(); }}, msgr{messenger}, + auth_registry{&cct}, auth_handler{auth_handler} {} @@ -382,6 +383,29 @@ AuthAuthorizer* Client::get_authorizer(peer_type_t peer) const return ms_get_authorizer(peer); } +std::pair, std::vector> +Client::get_supported_auth_methods(int peer_type) +{ + std::vector methods; + std::vector modes; + auth_registry.get_supported_methods(peer_type, &methods, &modes); + return {methods, modes}; +} + +uint32_t Client::pick_con_mode(int peer_type, + uint32_t auth_method, + const std::vector& preferred_modes) +{ + return auth_registry.pick_mode(peer_type, auth_method, preferred_modes); +} + +AuthAuthorizeHandler* Client::get_auth_authorize_handler(int peer_type, + int auth_method) +{ + return auth_registry.get_handler(peer_type, auth_method); +} + + int Client::handle_auth_request(ceph::net::ConnectionRef con, AuthConnectionMetaRef auth_meta, bool more, diff --git a/src/crimson/mon/MonClient.h b/src/crimson/mon/MonClient.h index c96bf80f1295..4d2c353ea7fd 100644 --- a/src/crimson/mon/MonClient.h +++ b/src/crimson/mon/MonClient.h @@ -9,7 +9,9 @@ #include #include +#include "auth/AuthRegistry.h" #include "auth/KeyRing.h" +#include "common/ceph_context.h" #include "crimson/auth/AuthServer.h" #include "crimson/common/auth_service.h" @@ -26,6 +28,7 @@ namespace ceph::net { class Messenger; } +struct AuthAuthorizeHandler; class AuthMethodList; class MAuthReply; struct MMonMap; @@ -56,7 +59,6 @@ class Client : public ceph::net::Dispatcher, seastar::gate tick_gate; ceph::net::Messenger& msgr; - ceph::common::AuthHandler& auth_handler; // commands using get_version_t = seastar::future; @@ -91,13 +93,26 @@ public: seastar::future<> renew_subs(); // AuthService methods AuthAuthorizer* get_authorizer(peer_type_t peer) const override; + +private: // AuthServer methods + std::pair, std::vector> + get_supported_auth_methods(int peer_type) final; + uint32_t pick_con_mode(int peer_type, + uint32_t auth_method, + const std::vector& preferred_modes) final; + AuthAuthorizeHandler* get_auth_authorize_handler(int peer_type, + int auth_method) final; int handle_auth_request(ceph::net::ConnectionRef conn, AuthConnectionMetaRef auth_meta, bool more, uint32_t auth_method, const ceph::bufferlist& payload, - ceph::bufferlist *reply); + ceph::bufferlist *reply) final; + + CephContext cct; // for auth_registry + AuthRegistry auth_registry; + ceph::common::AuthHandler& auth_handler; private: void tick();