From: Kefu Chai Date: Sat, 6 Apr 2019 12:59:42 +0000 (+0800) Subject: crimson/auth: implement AuthServer methods X-Git-Tag: v15.1.0~2987^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=30c822120a903f31417c3e2a677eedbce461f002;p=ceph.git crimson/auth: implement AuthServer methods Signed-off-by: Kefu Chai --- diff --git a/src/crimson/auth/AuthServer.h b/src/crimson/auth/AuthServer.h index 7fa4cf4d3f8e..527bb23a76b0 100644 --- a/src/crimson/auth/AuthServer.h +++ b/src/crimson/auth/AuthServer.h @@ -4,7 +4,9 @@ #pragma once #include +#include "common/ceph_context.h" #include "auth/AuthAuthorizeHandler.h" +#include "auth/AuthRegistry.h" #include "crimson/net/Fwd.h" namespace ceph::auth { @@ -13,41 +15,32 @@ namespace ceph::auth { class AuthServer { public: // TODO: - // AuthRegistry auth_registry; - - AuthServer() {} + AuthServer() + : auth_registry{&cct} + {} virtual ~AuthServer() {} // Get authentication methods and connection modes for the given peer type virtual std::pair, std::vector> - get_supported_auth_methods( - int peer_type) { - // std::vector methods; - // std::vector modes; - // auth_registry.get_supported_methods(peer_type, &methods, &modes); - return {{CEPH_AUTH_NONE}, {CEPH_AUTH_NONE}}; + 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}; } - // Get support connection modes for the given peer type and auth method virtual uint32_t 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); - ceph_assert(auth_method == CEPH_AUTH_NONE); - ceph_assert(preferred_modes.size() && - preferred_modes[0] == CEPH_CON_MODE_CRC); - return CEPH_CON_MODE_CRC; + return auth_registry.pick_mode(peer_type, auth_method, preferred_modes); } - // return an AuthAuthorizeHandler for the given peer type and auth method AuthAuthorizeHandler *get_auth_authorize_handler( int peer_type, int auth_method) { - // return auth_registry.get_handler(peer_type, auth_method); - return nullptr; + return auth_registry.get_handler(peer_type, auth_method); } - // Handle an authentication request on an incoming connection virtual int handle_auth_request( ceph::net::ConnectionRef conn, @@ -56,6 +49,10 @@ public: uint32_t auth_method, const bufferlist& bl, bufferlist *reply) = 0; + +private: + CephContext cct; // for auth_registry + AuthRegistry auth_registry; }; } // namespace ceph::auth