mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
fix zero-access user creation
This commit is contained in:
parent
30acb1b653
commit
a460001bae
@ -75,6 +75,7 @@ User::User(const String & name_, const String & config_elem, const Poco::Util::A
|
|||||||
const auto config_sub_elem = config_elem + ".allow_databases";
|
const auto config_sub_elem = config_elem + ".allow_databases";
|
||||||
if (config.has(config_sub_elem))
|
if (config.has(config_sub_elem))
|
||||||
{
|
{
|
||||||
|
has_allowed_databases = true;
|
||||||
Poco::Util::AbstractConfiguration::Keys config_keys;
|
Poco::Util::AbstractConfiguration::Keys config_keys;
|
||||||
config.keys(config_sub_elem, config_keys);
|
config.keys(config_sub_elem, config_keys);
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ User::User(const String & name_, const String & config_elem, const Poco::Util::A
|
|||||||
const auto config_dictionary_sub_elem = config_elem + ".allow_dictionaries";
|
const auto config_dictionary_sub_elem = config_elem + ".allow_dictionaries";
|
||||||
if (config.has(config_dictionary_sub_elem))
|
if (config.has(config_dictionary_sub_elem))
|
||||||
{
|
{
|
||||||
|
has_allowed_dictionaries = true;
|
||||||
Poco::Util::AbstractConfiguration::Keys config_keys;
|
Poco::Util::AbstractConfiguration::Keys config_keys;
|
||||||
config.keys(config_dictionary_sub_elem, config_keys);
|
config.keys(config_dictionary_sub_elem, config_keys);
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ struct User
|
|||||||
String profile;
|
String profile;
|
||||||
String quota;
|
String quota;
|
||||||
|
|
||||||
|
//if true then allowed_X was defined in user
|
||||||
|
bool has_allowed_databases = false;
|
||||||
|
bool has_allowed_dictionaries = false;
|
||||||
|
|
||||||
AllowedClientHosts allowed_client_hosts;
|
AllowedClientHosts allowed_client_hosts;
|
||||||
|
|
||||||
/// List of allowed databases.
|
/// List of allowed databases.
|
||||||
|
@ -63,7 +63,7 @@ bool UsersManager::hasAccessToDatabase(const std::string & user_name, const std:
|
|||||||
throw Exception("Unknown user " + user_name, ErrorCodes::UNKNOWN_USER);
|
throw Exception("Unknown user " + user_name, ErrorCodes::UNKNOWN_USER);
|
||||||
|
|
||||||
auto user = it->second;
|
auto user = it->second;
|
||||||
return user->databases.empty() || user->databases.count(database_name);
|
return !user->has_allowed_databases || user->databases.count(database_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UsersManager::hasAccessToDictionary(const std::string & user_name, const std::string & dictionary_name) const
|
bool UsersManager::hasAccessToDictionary(const std::string & user_name, const std::string & dictionary_name) const
|
||||||
@ -74,6 +74,6 @@ bool UsersManager::hasAccessToDictionary(const std::string & user_name, const st
|
|||||||
throw Exception("Unknown user " + user_name, ErrorCodes::UNKNOWN_USER);
|
throw Exception("Unknown user " + user_name, ErrorCodes::UNKNOWN_USER);
|
||||||
|
|
||||||
auto user = it->second;
|
auto user = it->second;
|
||||||
return user->dictionaries.empty() || user->dictionaries.count(dictionary_name);
|
return !user->has_allowed_dictionaries || user->dictionaries.count(dictionary_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user