mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
make auth_type a vector of int8_t and auth_params a json array
This commit is contained in:
parent
8eda32600f
commit
0404a8e800
@ -16,6 +16,7 @@
|
||||
#include <Parsers/Access/ASTRolesOrUsersSet.h>
|
||||
#include <Poco/JSON/JSON.h>
|
||||
#include <Poco/JSON/Object.h>
|
||||
#include <Poco/JSON/Array.h>
|
||||
#include <Poco/JSON/Stringifier.h>
|
||||
#include <Poco/JSONString.h>
|
||||
|
||||
@ -48,8 +49,8 @@ ColumnsDescription StorageSystemUsers::getColumnsDescription()
|
||||
{"name", std::make_shared<DataTypeString>(), "User name."},
|
||||
{"id", std::make_shared<DataTypeUUID>(), "User ID."},
|
||||
{"storage", std::make_shared<DataTypeString>(), "Path to the storage of users. Configured in the access_control_path parameter."},
|
||||
{"auth_type", std::make_shared<DataTypeEnum8>(getAuthenticationTypeEnumValues()),
|
||||
"Shows the authentication type. "
|
||||
{"auth_type", std::make_shared<DataTypeArray>(std::make_shared<DataTypeEnum8>(getAuthenticationTypeEnumValues())),
|
||||
"Shows the authentication types. "
|
||||
"There are multiple ways of user identification: "
|
||||
"with no password, with plain text password, with SHA256-encoded password, "
|
||||
"with double SHA-1-encoded password or with bcrypt-encoded password."
|
||||
@ -97,7 +98,8 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
auto & column_name = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||
auto & column_id = assert_cast<ColumnUUID &>(*res_columns[column_index++]).getData();
|
||||
auto & column_storage = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||
auto & column_auth_type = assert_cast<ColumnInt8 &>(*res_columns[column_index++]).getData();
|
||||
auto & column_auth_type = assert_cast<ColumnInt8 &>(assert_cast<ColumnArray &>(*res_columns[column_index]).getData());
|
||||
auto & column_auth_type_offsets = assert_cast<ColumnArray &>(*res_columns[column_index++]).getOffsets();
|
||||
auto & column_auth_params = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||
auto & column_host_ip = assert_cast<ColumnString &>(assert_cast<ColumnArray &>(*res_columns[column_index]).getData());
|
||||
auto & column_host_ip_offsets = assert_cast<ColumnArray &>(*res_columns[column_index++]).getOffsets();
|
||||
@ -119,11 +121,10 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
auto & column_grantees_except_offsets = assert_cast<ColumnArray &>(*res_columns[column_index++]).getOffsets();
|
||||
auto & column_default_database = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||
|
||||
// todo arthur check this
|
||||
auto add_row = [&](const String & name,
|
||||
const UUID & id,
|
||||
const String & storage_name,
|
||||
const AuthenticationData & auth_data,
|
||||
const std::vector<AuthenticationData> & authentication_methods,
|
||||
const AllowedClientHosts & allowed_hosts,
|
||||
const RolesOrUsersSet & default_roles,
|
||||
const RolesOrUsersSet & grantees,
|
||||
@ -132,12 +133,13 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
column_name.insertData(name.data(), name.length());
|
||||
column_id.push_back(id.toUnderType());
|
||||
column_storage.insertData(storage_name.data(), storage_name.length());
|
||||
column_auth_type.push_back(static_cast<Int8>(auth_data.getType()));
|
||||
|
||||
if (auth_data.getType() == AuthenticationType::LDAP ||
|
||||
auth_data.getType() == AuthenticationType::KERBEROS ||
|
||||
auth_data.getType() == AuthenticationType::SSL_CERTIFICATE)
|
||||
Poco::JSON::Array json_array;
|
||||
|
||||
for (const auto & auth_data : authentication_methods)
|
||||
{
|
||||
column_auth_type.insertValue(static_cast<Int8>(auth_data.getType()));
|
||||
|
||||
Poco::JSON::Object auth_params_json;
|
||||
|
||||
if (auth_data.getType() == AuthenticationType::LDAP)
|
||||
@ -165,18 +167,17 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
auth_params_json.set("subject_alt_names", subject_alt_names);
|
||||
}
|
||||
|
||||
std::ostringstream oss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
|
||||
oss.exceptions(std::ios::failbit);
|
||||
Poco::JSON::Stringifier::stringify(auth_params_json, oss);
|
||||
const auto str = oss.str();
|
||||
json_array.add(auth_params_json);
|
||||
}
|
||||
|
||||
column_auth_params.insertData(str.data(), str.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
static constexpr std::string_view empty_json{"{}"};
|
||||
column_auth_params.insertData(empty_json.data(), empty_json.length());
|
||||
}
|
||||
column_auth_type_offsets.push_back(column_auth_type.size());
|
||||
|
||||
std::ostringstream oss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
|
||||
oss.exceptions(std::ios::failbit);
|
||||
Poco::JSON::Stringifier::stringify(json_array, oss);
|
||||
const auto authentication_params_str = oss.str();
|
||||
|
||||
column_auth_params.insertData(authentication_params_str.data(), authentication_params_str.size());
|
||||
|
||||
if (allowed_hosts.containsAnyHost())
|
||||
{
|
||||
@ -248,7 +249,7 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
if (!storage)
|
||||
continue;
|
||||
|
||||
add_row(user->getName(), id, storage->getStorageName(), user->authentication_methods.back(), user->allowed_client_hosts,
|
||||
add_row(user->getName(), id, storage->getStorageName(), user->authentication_methods, user->allowed_client_hosts,
|
||||
user->default_roles, user->grantees, user->default_database);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user