我希望限制默认用户从特定数据库读取表,但revoke命令会给出以下异常。
REVOKE SELECT ON test_db.* FROM default
Received exception from server (version 20.5.2):
Code: 495. DB::Exception: Received from localhost:9000. DB::Exception: Cannot update user `default` in [users.xml] because this storage is readonly. users.xml拥有666权限。我想知道如何做到这一点,这样默认的用户就不能查看给定数据库中的表。
发布于 2020-12-09 19:16:24
管理用户有两种方法。旧的XML方式和新的创建/授予/RBAC。
用户默认值由旧的XML-way(硬编码为clickhouse源代码)创建。
您可以完全删除此用户的“默认”。
cat /etc/clickhouse-server/conf.d/z_user_def_remove.xml
<?xml version="1.0" ?>
<yandex>
<users>
<default remove="remove"></default>
</users>
</yandex>--我用z_命名了该文件,以便将其应用到末尾(作为最后一个文件)。
或者可以限制此用户的数据库“默认”。
cat /etc/clickhouse-server/conf.d/user_def_db.xml
<?xml version="1.0" ?>
<yandex>
<users>
<default>
<allow_databases>
<database>system</database>
</allow_databases>
</default>
</users>
</yandex>发布于 2020-12-09 18:52:27
这个答案是基于对默认配置文件和服务器间凭据使用默认设置的事实。
我不确定是否应该修改默认用户并在集群之外进行访问。默认情况下,它具有特殊用途,如集群中的服务器间交互。
我建议限制在集群节点内使用默认用户:
<!-- users.xml -->
..
<profiles>
<default>
<!-- default-profile is full-access profile (like super user).
Do NOT restrict permissions of default-profile. The default profile has a special purpose: it must always be present
and is applied when starting the server and used by internal processes (Buffer storage, Distibuted DDL worker and so on)
-->
..
</default>
..
</profiles>
<users>
<!--
default user that used ONLY for inter-server interaction.
Password intentionally is EMPTY so this account MUST be restricted only inner network.
-->
<default>
<password replace="replace"></password>
<profile replace="replace">default</profile>
<networks replace="replace">
<!-- Restrict account to hosts belonging to the cluster. -->
<host>clickhouse-node-1</host>
<host>clickhouse-node-2</host>
..
</networks>
</default>
..
</users>
..并为您的目标添加一个专用用户,而不是使用默认目标。
https://stackoverflow.com/questions/65219899
复制相似问题