]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: new ms_handle_authentication, add fields to Connection
authorSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 15:40:34 +0000 (11:40 -0400)
committerSage Weil <sage@redhat.com>
Sun, 14 Oct 2018 16:59:20 +0000 (11:59 -0500)
Lay some groundwork to eliminate ms_verify_authorizer.

Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/Connection.h
src/msg/Dispatcher.h
src/test/messenger/simple_dispatcher.h
src/test/msgr/perf_msgr_client.cc
src/test/msgr/perf_msgr_server.cc
src/test/msgr/test_msgr.cc

index 0744f19d38c15b83dbd80a53f2fbe6bf8a1f30f7..39b277310e30eff994f86ab9e0bc9af1890e122e 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <boost/intrusive_ptr.hpp>
 
+#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<ceph_tid_t,pair<bufferlist,int> > 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<Connection>;
   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; }
index 4596abade810bf50965247f3e913913ffa06e577..998b2393098bfcbeddd8a2f95966ded1657354d8 100644 (file)
@@ -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.
index 8b84ff4b6d2f0dba2038372087ea4520404c8fec..adef942f92b751a4d506b17be51968f6bb984ae7 100644 (file)
@@ -121,7 +121,9 @@ public:
     isvalid = true;
     return true;
   };
-
+  int ms_handle_authentication(Connection *con) override {
+    return 1;
+  }
 };
 
 #endif /* SIMPLEDISPATCHER_H_ */
index 37b1a19636616237464faf8e596058d19a6a77f8..aaf3be46780f0fcd69633a7073dfe96b0f62469d 100644 (file)
@@ -63,6 +63,9 @@ class MessengerClient {
       isvalid = true;
       return true;
     }
+    int ms_handle_authentication(Connection *con) override {
+      return 1;
+    }
   };
 
   class ClientThread : public Thread {
index 6b5e933d7e63d43e743d80ffde3aa69e90621c55..e3e6dc740e56d4b43d38d7d002de6fa2968a072b 100644 (file)
@@ -106,6 +106,9 @@ class ServerDispatcher : public Dispatcher {
     isvalid = true;
     return true;
   }
+  int ms_handle_authentication(Connection *con) override {
+    return 1;
+  }
 };
 
 class MessengerServer {
index e2a17bc006039b61dba4432877b99c1c61f135ff..063465498cc5265887cda3dac141a5872e2b4d62 100644 (file)
@@ -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;
+  }
 };