From abb374aec433da6b3c8a3f92cdf59746f5e70d9d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 9 Apr 2019 14:35:24 +0800 Subject: [PATCH] crimson/auth: move dummy impl of AuthServer to DummyAuth Signed-off-by: Kefu Chai --- src/crimson/auth/AuthServer.h | 33 ++++++++------------------------- src/crimson/auth/DummyAuth.h | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/crimson/auth/AuthServer.h b/src/crimson/auth/AuthServer.h index 527bb23a76b..bca0b43871a 100644 --- a/src/crimson/auth/AuthServer.h +++ b/src/crimson/auth/AuthServer.h @@ -3,44 +3,31 @@ #pragma once +#include +#include #include -#include "common/ceph_context.h" -#include "auth/AuthAuthorizeHandler.h" -#include "auth/AuthRegistry.h" #include "crimson/net/Fwd.h" +struct AuthAuthorizeHandler; + namespace ceph::auth { -// TODO: revisit interfaces for non-dummy implementations class AuthServer { public: - // TODO: - 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 {methods, modes}; - } + get_supported_auth_methods(int peer_type) = 0; // 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); - } + const std::vector& preferred_modes) = 0; // return an AuthAuthorizeHandler for the given peer type and auth method - AuthAuthorizeHandler *get_auth_authorize_handler( + virtual AuthAuthorizeHandler* get_auth_authorize_handler( int peer_type, - int auth_method) { - return auth_registry.get_handler(peer_type, auth_method); - } + int auth_method) = 0; // Handle an authentication request on an incoming connection virtual int handle_auth_request( ceph::net::ConnectionRef conn, @@ -49,10 +36,6 @@ public: uint32_t auth_method, const bufferlist& bl, bufferlist *reply) = 0; - -private: - CephContext cct; // for auth_registry - AuthRegistry auth_registry; }; } // namespace ceph::auth diff --git a/src/crimson/auth/DummyAuth.h b/src/crimson/auth/DummyAuth.h index e6fc720cad6..b3b2dc62089 100644 --- a/src/crimson/auth/DummyAuth.h +++ b/src/crimson/auth/DummyAuth.h @@ -12,6 +12,25 @@ public: DummyAuthClientServer() {} // client + std::pair, std::vector> + get_supported_auth_methods(int peer_type) final { + return {{CEPH_AUTH_NONE}, {CEPH_AUTH_NONE}}; + } + + uint32_t pick_con_mode(int peer_type, + uint32_t auth_method, + const std::vector& preferred_modes) final { + ceph_assert(auth_method == CEPH_AUTH_NONE); + ceph_assert(preferred_modes.size() && + preferred_modes[0] == CEPH_CON_MODE_CRC); + return CEPH_CON_MODE_CRC; + } + + AuthAuthorizeHandler* get_auth_authorize_handler(int peer_type, + int auth_method) final { + return nullptr; + } + int get_auth_request( ceph::net::ConnectionRef conn, AuthConnectionMetaRef auth_meta, -- 2.39.5