]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/auth: move dummy impl of AuthServer to DummyAuth
authorKefu Chai <kchai@redhat.com>
Tue, 9 Apr 2019 06:35:24 +0000 (14:35 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 9 Apr 2019 06:35:24 +0000 (14:35 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/auth/AuthServer.h
src/crimson/auth/DummyAuth.h

index 527bb23a76b0508f2b51f1afad4d1c6ec9b35f75..bca0b43871a856f0ede932a7e7aa5d548f63d798 100644 (file)
@@ -3,44 +3,31 @@
 
 #pragma once
 
+#include <cstdint>
+#include <utility>
 #include <vector>
-#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<uint32_t>, std::vector<uint32_t>>
-  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};
-  }
+  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<uint32_t>& preferred_modes) {
-    return auth_registry.pick_mode(peer_type, auth_method, preferred_modes);
-  }
+    const std::vector<uint32_t>& 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
index e6fc720cad6efd69dbfa09d1ae1d839f123e170a..b3b2dc62089e6dad06c812206e2c96319ce8b993 100644 (file)
@@ -12,6 +12,25 @@ public:
   DummyAuthClientServer() {}
 
   // client
+  std::pair<std::vector<uint32_t>, std::vector<uint32_t>>
+  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<uint32_t>& 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,