mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Better
This commit is contained in:
parent
63f8a3275b
commit
6c776f4483
@ -70,7 +70,7 @@ enum class AccessType
|
||||
M(ALTER_FREEZE_PARTITION, "FREEZE PARTITION, UNFREEZE", TABLE, ALTER_TABLE) \
|
||||
\
|
||||
M(ALTER_DATABASE_SETTINGS, "ALTER DATABASE SETTING, ALTER MODIFY DATABASE SETTING, MODIFY DATABASE SETTING", DATABASE, ALTER_DATABASE) /* allows to execute ALTER MODIFY SETTING */\
|
||||
M(ALTER_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_CONTROL) /* allows to execute ALTER NAMED COLLECTION */\
|
||||
M(ALTER_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) /* allows to execute ALTER NAMED COLLECTION */\
|
||||
\
|
||||
M(ALTER_TABLE, "", GROUP, ALTER) \
|
||||
M(ALTER_DATABASE, "", GROUP, ALTER) \
|
||||
@ -92,7 +92,7 @@ enum class AccessType
|
||||
M(CREATE_ARBITRARY_TEMPORARY_TABLE, "", GLOBAL, CREATE) /* allows to create and manipulate temporary tables
|
||||
with arbitrary table engine */\
|
||||
M(CREATE_FUNCTION, "", GLOBAL, CREATE) /* allows to execute CREATE FUNCTION */ \
|
||||
M(CREATE_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_CONTROL) /* allows to execute CREATE NAMED COLLECTION */ \
|
||||
M(CREATE_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) /* allows to execute CREATE NAMED COLLECTION */ \
|
||||
M(CREATE, "", GROUP, ALL) /* allows to execute {CREATE|ATTACH} */ \
|
||||
\
|
||||
M(DROP_DATABASE, "", DATABASE, DROP) /* allows to execute {DROP|DETACH} DATABASE */\
|
||||
@ -101,7 +101,7 @@ enum class AccessType
|
||||
implicitly enabled by the grant DROP_TABLE */\
|
||||
M(DROP_DICTIONARY, "", DICTIONARY, DROP) /* allows to execute {DROP|DETACH} DICTIONARY */\
|
||||
M(DROP_FUNCTION, "", GLOBAL, DROP) /* allows to execute DROP FUNCTION */\
|
||||
M(DROP_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_CONTROL) /* allows to execute DROP NAMED COLLECTION */\
|
||||
M(DROP_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) /* allows to execute DROP NAMED COLLECTION */\
|
||||
M(DROP, "", GROUP, ALL) /* allows to execute {DROP|DETACH} */\
|
||||
\
|
||||
M(UNDROP_TABLE, "", TABLE, ALL) /* allows to execute {UNDROP} TABLE */\
|
||||
@ -140,10 +140,10 @@ enum class AccessType
|
||||
M(SHOW_SETTINGS_PROFILES, "SHOW PROFILES, SHOW CREATE SETTINGS PROFILE, SHOW CREATE PROFILE", GLOBAL, SHOW_ACCESS) \
|
||||
M(SHOW_ACCESS, "", GROUP, ACCESS_MANAGEMENT) \
|
||||
M(ACCESS_MANAGEMENT, "", GROUP, ALL) \
|
||||
M(SHOW_NAMED_COLLECTIONS, "SHOW NAMED COLLECTIONS", NAMED_COLLECTION, NAMED_COLLECTION_CONTROL) \
|
||||
M(SHOW_NAMED_COLLECTIONS_SECRETS, "SHOW NAMED COLLECTIONS SECRETS", NAMED_COLLECTION, NAMED_COLLECTION_CONTROL) \
|
||||
M(USE_NAMED_COLLECTION, "USE NAMED COLLECTION", NAMED_COLLECTION, NAMED_COLLECTION_CONTROL) \
|
||||
M(NAMED_COLLECTION_CONTROL, "", NAMED_COLLECTION, ALL) \
|
||||
M(SHOW_NAMED_COLLECTIONS, "SHOW NAMED COLLECTIONS", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) \
|
||||
M(SHOW_NAMED_COLLECTIONS_SECRETS, "SHOW NAMED COLLECTIONS SECRETS", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) \
|
||||
M(USE_NAMED_COLLECTION, "NAMED COLLECTION USAGE, NAMED COLLECTION", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) \
|
||||
M(NAMED_COLLECTION_ADMIN, "NAMED COLLECTION CONTROL", NAMED_COLLECTION, ALL) \
|
||||
\
|
||||
M(SYSTEM_SHUTDOWN, "SYSTEM KILL, SHUTDOWN", GLOBAL, SYSTEM) \
|
||||
M(SYSTEM_DROP_DNS_CACHE, "SYSTEM DROP DNS, DROP DNS CACHE, DROP DNS", GLOBAL, SYSTEM_DROP_CACHE) \
|
||||
|
@ -328,7 +328,7 @@ namespace
|
||||
|
||||
if (!named_collection_control)
|
||||
{
|
||||
user->access.revoke(AccessType::NAMED_COLLECTION_CONTROL);
|
||||
user->access.revoke(AccessType::NAMED_COLLECTION_ADMIN);
|
||||
}
|
||||
|
||||
if (!show_named_collections_secrets)
|
||||
|
@ -76,6 +76,8 @@ MutableNamedCollectionPtr tryGetNamedCollectionWithOverrides(
|
||||
if (!collection_name.has_value())
|
||||
return nullptr;
|
||||
|
||||
context->checkAccess(AccessType::USE_NAMED_COLLECTION, *collection_name);
|
||||
|
||||
NamedCollectionPtr collection;
|
||||
if (throw_unknown_collection)
|
||||
collection = NamedCollectionFactory::instance().get(*collection_name);
|
||||
@ -85,8 +87,6 @@ MutableNamedCollectionPtr tryGetNamedCollectionWithOverrides(
|
||||
if (!collection)
|
||||
return nullptr;
|
||||
|
||||
context->checkAccess(AccessType::USE_NAMED_COLLECTION, *collection_name);
|
||||
|
||||
auto collection_copy = collection->duplicate();
|
||||
|
||||
if (asts.size() == 1)
|
||||
|
@ -57,6 +57,16 @@ def started_cluster():
|
||||
],
|
||||
user_configs=["configs/access.xml", "configs/users.xml"],
|
||||
)
|
||||
cluster.add_instance(
|
||||
"dummy_without_named_collections",
|
||||
with_minio=True,
|
||||
main_configs=[
|
||||
"configs/defaultS3.xml",
|
||||
"configs/named_collections.xml",
|
||||
"configs/schema_cache.xml",
|
||||
],
|
||||
user_configs=["configs/access.xml"],
|
||||
)
|
||||
cluster.add_instance(
|
||||
"s3_max_redirects",
|
||||
with_minio=True,
|
||||
@ -919,7 +929,7 @@ def test_truncate_table(started_cluster):
|
||||
|
||||
def test_predefined_connection_configuration(started_cluster):
|
||||
bucket = started_cluster.minio_bucket
|
||||
instance = started_cluster.instances["dummy"] # type: ClickHouseInstance
|
||||
instance = started_cluster.instances["dummy_without_named_collections"] # type: ClickHouseInstance
|
||||
name = "test_table"
|
||||
|
||||
instance.query("CREATE USER user")
|
||||
@ -944,7 +954,7 @@ def test_predefined_connection_configuration(started_cluster):
|
||||
in error
|
||||
)
|
||||
|
||||
instance.query("GRANT USE NAMED COLLECTION ON s3_conf1 TO user", user="admin")
|
||||
instance.query("GRANT NAMED COLLECTION ON s3_conf1 TO user", user="admin")
|
||||
instance.query(
|
||||
f"CREATE TABLE {name} (id UInt32) ENGINE = S3(s3_conf1, format='CSV')",
|
||||
user="user",
|
||||
@ -960,8 +970,17 @@ def test_predefined_connection_configuration(started_cluster):
|
||||
assert result == instance.query("SELECT number FROM numbers(10)")
|
||||
|
||||
error = instance.query_and_get_error("SELECT * FROM s3(no_collection)")
|
||||
assert "There is no named collection `no_collection`" in error
|
||||
assert (
|
||||
"To execute this query it's necessary to have grant USE NAMED COLLECTION ON no_collection"
|
||||
in error
|
||||
)
|
||||
error = instance.query_and_get_error("SELECT * FROM s3(no_collection)", user="user")
|
||||
assert (
|
||||
"To execute this query it's necessary to have grant USE NAMED COLLECTION ON no_collection"
|
||||
in error
|
||||
)
|
||||
instance = started_cluster.instances["dummy"] # has named collection access
|
||||
error = instance.query_and_get_error("SELECT * FROM s3(no_collection)")
|
||||
assert "There is no named collection `no_collection`" in error
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user