| 418 | } |
| 419 | |
| 420 | void MySQLHandler::authenticate(const String & user_name, const String & auth_plugin_name, const String & initial_auth_response) |
| 421 | { |
| 422 | try |
| 423 | { |
| 424 | const auto user_authentication_types = session->getAuthenticationTypesOrLogInFailure(user_name); |
| 425 | |
| 426 | for (const auto user_authentication_type : user_authentication_types) |
| 427 | { |
| 428 | // For compatibility with JavaScript MySQL client, Native41 authentication plugin is used when possible |
| 429 | // (if password is specified using double SHA1). Otherwise, SHA256 plugin is used. |
| 430 | if (user_authentication_type == DB::AuthenticationType::SHA256_PASSWORD) |
| 431 | { |
| 432 | authPluginSSL(); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | std::optional<String> auth_response = auth_plugin_name == auth_plugin->getName() ? std::make_optional<String>(initial_auth_response) : std::nullopt; |
| 437 | auth_plugin->authenticate(user_name, *session, auth_response, packet_endpoint, secure_connection, socket().peerAddress()); |
| 438 | } |
| 439 | catch (const Exception & exc) |
| 440 | { |
| 441 | LOG_ERROR(log, "Authentication for user {} failed.", user_name); |
| 442 | packet_endpoint->sendPacket(ERRPacket(exc.code(), mysql_error_code, exc.message())); |
| 443 | throw; |
| 444 | } |
| 445 | LOG_DEBUG(log, "Authentication for user {} succeeded.", user_name); |
| 446 | } |
| 447 | |
| 448 | void MySQLHandler::comInitDB(ReadBuffer & payload) |
| 449 | { |
nothing calls this directly
no test coverage detected