mirror of
https://github.com/ceph/ceph
synced 2025-02-24 03:27:10 +00:00
crimson/auth: move dummy impl of AuthServer to DummyAuth
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
7cbbe9acea
commit
abb374aec4
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user