}
}
+uint32_t AuthRegistry::pick_mode(
+ int peer_type,
+ uint32_t auth_method,
+ const std::vector<uint32_t>& preferred_modes)
+{
+ std::vector<uint32_t> allowed_modes;
+ get_supported_modes(peer_type, auth_method, &allowed_modes);
+ for (auto mode : preferred_modes) {
+ if (std::find(allowed_modes.begin(), allowed_modes.end(), mode)
+ != allowed_modes.end()) {
+ return mode;
+ }
+ }
+ ldout(cct,1) << "failed to pick con mode from client's " << preferred_modes
+ << " and our " << allowed_modes << dendl;
+ return CEPH_CON_MODE_UNKNOWN;
+}
+
AuthAuthorizeHandler *AuthRegistry::get_handler(int peer_type, int method)
{
std::scoped_lock l{lock};
uint32_t auth_method,
std::vector<uint32_t> *modes);
+ uint32_t pick_mode(int peer_type,
+ uint32_t auth_method,
+ const std::vector<uint32_t>& preferred_modes);
+
AuthAuthorizeHandler *get_handler(int peer_type, int method);
const char** get_tracked_conf_keys() const override;
auth_registry.get_supported_modes(peer_type, auth_method, modes);
}
+ /// 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);
+ }
+
/// return an AuthAuthorizeHandler for the given peer type and auth method
AuthAuthorizeHandler *get_auth_authorize_handler(
int peer_type,
<< ", payload_len=" << request.auth_payload().length() << ")"
<< dendl;
auth_meta->auth_method = request.method();
-
- // select a connection mode
- auto& preferred_modes = request.preferred_modes();
- std::vector<uint32_t> allowed_modes;
- messenger->auth_server->get_supported_con_modes(
- connection->get_peer_type(), auth_meta->auth_method, &allowed_modes);
- for (auto mode : preferred_modes) {
- if (std::find(allowed_modes.begin(), allowed_modes.end(), mode)
- != allowed_modes.end()) {
- auth_meta->con_mode = mode;
- break;
- }
- }
+ auth_meta->con_mode = messenger->auth_server->pick_con_mode(
+ connection->get_peer_type(), auth_meta->auth_method,
+ request.preferred_modes());
if (auth_meta->con_mode == CEPH_CON_MODE_UNKNOWN) {
- ldout(cct,1) << "failed to pick con mode from client's " << preferred_modes
- << " and our " << allowed_modes << dendl;
return _auth_bad_method(-EOPNOTSUPP);
}
return _handle_auth_request(request.auth_payload(), false);