From eec65bada4fd5e828339e20794f264acd8bcd6c3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 15 Jun 2016 11:40:34 -0400 Subject: [PATCH] msg: new ms_handle_authentication, add fields to Connection Lay some groundwork to eliminate ms_verify_authorizer. Signed-off-by: Sage Weil --- src/msg/Connection.h | 17 +++++++++++++++++ src/msg/Dispatcher.h | 13 +++++++++++++ src/test/messenger/simple_dispatcher.h | 4 +++- src/test/msgr/perf_msgr_client.cc | 3 +++ src/test/msgr/perf_msgr_server.cc | 3 +++ src/test/msgr/test_msgr.cc | 11 +++++++++++ 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/msg/Connection.h b/src/msg/Connection.h index 0744f19d38c15..39b277310e30e 100644 --- a/src/msg/Connection.h +++ b/src/msg/Connection.h @@ -20,6 +20,7 @@ #include +#include "auth/Auth.h" #include "common/RefCountedObj.h" #include "common/config.h" #include "common/debug.h" @@ -50,6 +51,13 @@ public: int rx_buffers_version; map > rx_buffers; + // authentication state + // FIXME make these private after ms_handle_authorizer is removed +public: + AuthCapsInfo peer_caps_info; + EntityName peer_name; + uint64_t peer_global_id = 0; + friend class boost::intrusive_ptr; friend class PipeConnection; @@ -144,6 +152,15 @@ public: */ virtual void mark_disposable() = 0; + AuthCapsInfo& get_peer_caps_info() { + return peer_caps_info; + } + const EntityName& get_peer_entity_name() { + return peer_name; + } + uint64_t get_peer_global_id() { + return peer_global_id; + } int get_peer_type() const { return peer_type; } void set_peer_type(int t) { peer_type = t; } diff --git a/src/msg/Dispatcher.h b/src/msg/Dispatcher.h index 4596abade810b..998b2393098bf 100644 --- a/src/msg/Dispatcher.h +++ b/src/msg/Dispatcher.h @@ -201,6 +201,19 @@ public: * @defgroup Authentication * @{ */ + /** + * handle successful authentication (msgr2) + * + * Authenticated result/state will be attached to the Connection. + * + * return 1 for success + * return 0 for no action (let another Dispatcher handle it) + * return <0 for failure (failure to parse caps, for instance) + */ + virtual int ms_handle_authentication(Connection *con) { + return 0; + } + /** * Retrieve the AuthAuthorizer for the given peer type. It might not * provide one if it knows there is no AuthAuthorizer for that type. diff --git a/src/test/messenger/simple_dispatcher.h b/src/test/messenger/simple_dispatcher.h index 8b84ff4b6d2f0..adef942f92b75 100644 --- a/src/test/messenger/simple_dispatcher.h +++ b/src/test/messenger/simple_dispatcher.h @@ -121,7 +121,9 @@ public: isvalid = true; return true; }; - + int ms_handle_authentication(Connection *con) override { + return 1; + } }; #endif /* SIMPLEDISPATCHER_H_ */ diff --git a/src/test/msgr/perf_msgr_client.cc b/src/test/msgr/perf_msgr_client.cc index 37b1a19636616..aaf3be46780f0 100644 --- a/src/test/msgr/perf_msgr_client.cc +++ b/src/test/msgr/perf_msgr_client.cc @@ -63,6 +63,9 @@ class MessengerClient { isvalid = true; return true; } + int ms_handle_authentication(Connection *con) override { + return 1; + } }; class ClientThread : public Thread { diff --git a/src/test/msgr/perf_msgr_server.cc b/src/test/msgr/perf_msgr_server.cc index 6b5e933d7e63d..e3e6dc740e56d 100644 --- a/src/test/msgr/perf_msgr_server.cc +++ b/src/test/msgr/perf_msgr_server.cc @@ -106,6 +106,9 @@ class ServerDispatcher : public Dispatcher { isvalid = true; return true; } + int ms_handle_authentication(Connection *con) override { + return 1; + } }; class MessengerServer { diff --git a/src/test/msgr/test_msgr.cc b/src/test/msgr/test_msgr.cc index e2a17bc006039..063465498cc52 100644 --- a/src/test/msgr/test_msgr.cc +++ b/src/test/msgr/test_msgr.cc @@ -206,6 +206,10 @@ class FakeDispatcher : public Dispatcher { return true; } + int ms_handle_authentication(Connection *con) override { + return 1; + } + void reply_message(Message *m) { MPing *rm = new MPing(); m->get_connection()->send_message(rm); @@ -925,6 +929,10 @@ class SyntheticDispatcher : public Dispatcher { return true; } + int ms_handle_authentication(Connection *con) override { + return 1; + } + void reply_message(const Message *m, Payload& pl) { pl.who = Payload::PONG; bufferlist bl; @@ -1471,6 +1479,9 @@ class MarkdownDispatcher : public Dispatcher { isvalid = true; return true; } + int ms_handle_authentication(Connection *con) override { + return 1; + } }; -- 2.39.5