mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Two ways to provide access to system.users: "GRANT SHOW USERS ON *.*" and "GRANT SELECT ON system.users"
This commit is contained in:
parent
ef3a24d20f
commit
c7cef91d4d
@ -36,8 +36,11 @@ NamesAndTypesList StorageSystemGrants::getNamesAndTypes()
|
||||
|
||||
void StorageSystemGrants::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_USERS | AccessType::SHOW_ROLES);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_USERS | AccessType::SHOW_ROLES);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<User>();
|
||||
boost::range::push_back(ids, access_control.findAll<Role>());
|
||||
|
||||
|
@ -66,8 +66,11 @@ NamesAndTypesList StorageSystemQuotaLimits::getNamesAndTypes()
|
||||
|
||||
void StorageSystemQuotaLimits::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<Quota>();
|
||||
|
||||
size_t column_index = 0;
|
||||
|
@ -78,7 +78,11 @@ NamesAndTypesList StorageSystemQuotaUsage::getNamesAndTypesImpl(bool add_column_
|
||||
|
||||
void StorageSystemQuotaUsage::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
|
||||
auto usage = context->getQuotaUsage();
|
||||
if (!usage)
|
||||
return;
|
||||
|
@ -53,8 +53,11 @@ NamesAndTypesList StorageSystemQuotas::getNamesAndTypes()
|
||||
|
||||
void StorageSystemQuotas::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<Quota>();
|
||||
|
||||
size_t column_index = 0;
|
||||
|
@ -15,7 +15,11 @@ NamesAndTypesList StorageSystemQuotasUsage::getNamesAndTypes()
|
||||
|
||||
void StorageSystemQuotasUsage::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_QUOTAS);
|
||||
|
||||
auto all_quotas_usage = context->getAccessControl().getAllQuotasUsage();
|
||||
StorageSystemQuotaUsage::fillDataImpl(res_columns, context, /* add_column_is_current = */ true, all_quotas_usage);
|
||||
}
|
||||
|
@ -31,8 +31,11 @@ NamesAndTypesList StorageSystemRoleGrants::getNamesAndTypes()
|
||||
|
||||
void StorageSystemRoleGrants::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_USERS | AccessType::SHOW_ROLES);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_USERS | AccessType::SHOW_ROLES);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<User>();
|
||||
boost::range::push_back(ids, access_control.findAll<Role>());
|
||||
|
||||
|
@ -27,8 +27,11 @@ NamesAndTypesList StorageSystemRoles::getNamesAndTypes()
|
||||
|
||||
void StorageSystemRoles::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_ROLES);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_ROLES);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<Role>();
|
||||
|
||||
size_t column_index = 0;
|
||||
|
@ -53,8 +53,11 @@ NamesAndTypesList StorageSystemRowPolicies::getNamesAndTypes()
|
||||
|
||||
void StorageSystemRowPolicies::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_ROW_POLICIES);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_ROW_POLICIES);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<RowPolicy>();
|
||||
|
||||
size_t column_index = 0;
|
||||
|
@ -37,8 +37,11 @@ NamesAndTypesList StorageSystemSettingsProfileElements::getNamesAndTypes()
|
||||
|
||||
void StorageSystemSettingsProfileElements::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_SETTINGS_PROFILES);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_SETTINGS_PROFILES);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<User>();
|
||||
boost::range::push_back(ids, access_control.findAll<Role>());
|
||||
boost::range::push_back(ids, access_control.findAll<SettingsProfile>());
|
||||
|
@ -34,8 +34,11 @@ NamesAndTypesList StorageSystemSettingsProfiles::getNamesAndTypes()
|
||||
|
||||
void StorageSystemSettingsProfiles::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_SETTINGS_PROFILES);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_SETTINGS_PROFILES);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<SettingsProfile>();
|
||||
|
||||
size_t column_index = 0;
|
||||
|
@ -60,8 +60,11 @@ NamesAndTypesList StorageSystemUsers::getNamesAndTypes()
|
||||
|
||||
void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
context->checkAccess(AccessType::SHOW_USERS);
|
||||
/// If "select_from_system_db_requires_grant" is enabled the access rights were already checked in InterpreterSelectQuery.
|
||||
const auto & access_control = context->getAccessControl();
|
||||
if (!access_control.doesSelectFromSystemDatabaseRequireGrant())
|
||||
context->checkAccess(AccessType::SHOW_USERS);
|
||||
|
||||
std::vector<UUID> ids = access_control.findAll<User>();
|
||||
|
||||
size_t column_index = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user