]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/mon: implement AuthServer methods
authorKefu Chai <kchai@redhat.com>
Tue, 9 Apr 2019 06:36:45 +0000 (14:36 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 9 Apr 2019 06:36:45 +0000 (14:36 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mon/MonClient.cc
src/crimson/mon/MonClient.h

index d47bf04cf13f4b1bc5e3a7f1db591cc979ea0f0a..0a6e1371b236ec490c317470ae43c4b2e154699a 100644 (file)
@@ -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<uint32_t>, std::vector<uint32_t>>
+Client::get_supported_auth_methods(int peer_type)
+{
+    std::vector<uint32_t> methods;
+    std::vector<uint32_t> 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<uint32_t>& 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,
index c96bf80f1295048fbdb5d5b3c26ab70267bebe63..4d2c353ea7fda40f19e034b351766148dd17780e 100644 (file)
@@ -9,7 +9,9 @@
 #include <seastar/core/lowres_clock.hh>
 #include <seastar/core/timer.hh>
 
+#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<version_t, version_t>;
@@ -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<uint32_t>, std::vector<uint32_t>>
+  get_supported_auth_methods(int peer_type) final;
+  uint32_t pick_con_mode(int peer_type,
+                        uint32_t auth_method,
+                        const std::vector<uint32_t>& 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();