MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / authenticate

Method authenticate

src/Server/MySQLHandler.cpp:420–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420void 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
448void MySQLHandler::comInitDB(ReadBuffer & payload)
449{

Callers

nothing calls this directly

Calls 7

ERRPacketClass · 0.85
sendPacketMethod · 0.80
getNameMethod · 0.45
peerAddressMethod · 0.45
codeMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected