magic(0),
socket_priority(-1),
cct(cct_),
- crcflags(get_default_crc_flags(cct->_conf)) {}
+ crcflags(get_default_crc_flags(cct->_conf)),
+ auth_ah_service_registry(
+ new AuthAuthorizeHandlerRegistry(
+ cct,
+ cct->_conf->auth_supported.empty() ?
+ cct->_conf->auth_service_required :
+ cct->_conf->auth_supported)),
+ auth_ah_cluster_registry(
+ new AuthAuthorizeHandlerRegistry(
+ cct,
+ cct->_conf->auth_supported.empty() ?
+ cct->_conf->auth_cluster_required :
+ cct->_conf->auth_supported))
+{}
void Messenger::set_endpoint_addr(const entity_addr_t& a,
const entity_name_t &name)
}
bool Messenger::ms_deliver_verify_authorizer(
- Connection *con, int peer_type,
- int protocol, bufferlist& authorizer, bufferlist& authorizer_reply,
- bool& isvalid, CryptoKey& session_key,
+ Connection *con,
+ int peer_type,
+ int protocol,
+ bufferlist& authorizer,
+ bufferlist& authorizer_reply,
+ bool& isvalid,
+ CryptoKey& session_key,
std::unique_ptr<AuthAuthorizerChallenge> *challenge)
{
- for (const auto& dispatcher : dispatchers) {
- if (dispatcher->ms_verify_authorizer(con, peer_type, protocol,
- authorizer,
- authorizer_reply,
- isvalid, session_key, challenge))
+ AuthAuthorizeHandler *ah = 0;
+ switch (peer_type) {
+ case CEPH_ENTITY_TYPE_MDS:
+ case CEPH_ENTITY_TYPE_MON:
+ case CEPH_ENTITY_TYPE_OSD:
+ ah = auth_ah_cluster_registry->get_handler(protocol);
+ break;
+ default:
+ ah = auth_ah_service_registry->get_handler(protocol);
+ }
+ if (get_mytype() == CEPH_ENTITY_TYPE_MON &&
+ peer_type != CEPH_ENTITY_TYPE_MON) {
+ // the monitor doesn't do authenticators for msgr1.
+ isvalid = true;
+ return true;
+ }
+ if (!ah) {
+ lderr(cct) << __func__ << " no AuthAuthorizeHandler found for protocol "
+ << protocol << dendl;
+ isvalid = false;
+ return false;
+ }
+
+ for (auto dis : dispatchers) {
+ KeyStore *ks = dis->ms_get_auth1_authorizer_keystore();
+ if (ks) {
+ isvalid = ah->verify_authorizer(
+ cct,
+ ks,
+ authorizer,
+ authorizer_reply,
+ con->peer_name,
+ con->peer_global_id,
+ con->peer_caps_info,
+ session_key,
+ challenge);
+ if (isvalid) {
+ dis->ms_handle_authentication(con);
+ }
return true;
+ }
}
return false;
}
#include <map>
#include <deque>
+#include <errno.h>
+#include <sstream>
+#include <memory>
+
#include "Message.h"
#include "Dispatcher.h"
#include "Policy.h"
#include "include/ceph_features.h"
#include "auth/Crypto.h"
#include "common/item_history.h"
+#include "auth/AuthAuthorizeHandler.h"
+#include "include/ceph_assert.h"
#include <errno.h>
#include <sstream>
class Timer;
+class AuthAuthorizerHandlerRegistry;
+
class Messenger {
private:
std::deque<Dispatcher*> dispatchers;
int crcflags;
using Policy = ceph::net::Policy<Throttle>;
+
+protected:
+ // for authentication
+ std::unique_ptr<AuthAuthorizeHandlerRegistry> auth_ah_service_registry;
+ std::unique_ptr<AuthAuthorizeHandlerRegistry> auth_ah_cluster_registry;
+
+public:
/**
* Messenger constructor. Call this from your implementation.
* Messenger users should construct full implementations directly,