Access Control and Account Management
ClickHouse access entities:
- User account
-
- Row Policy
-
- Quota
You can configure access entities using:
SQL-driven workflow.
You need to this functionality.
Server configuration files and
config.xml
.
We recommend using SQL-driven workflow. Both of the configuration methods work simultaneously, so if you use the server configuration files for managing accounts and access rights, you can smoothly switch to SQL-driven workflow.
Warning
You can’t manage the same access entity by both configuration methods simultaneously.
To see all users, roles, profiles, etc. and all their grants use statement.
If you just started using ClickHouse, consider the following scenario:
- Enable SQL-driven access control and account management for the
default
user. - Log in to the
default
user account and create all the required users. Don’t forget to create an administrator account (). - for the
default
user and disable SQL-driven access control and account management for it.
- You can grant permissions for databases and tables even if they do not exist.
- If a table was deleted, all the privileges that correspond to this table are not revoked. This means that even if you create a new table with the same name later, all the privileges remain valid. To revoke privileges corresponding to the deleted table, you need to execute, for example, the
REVOKE ALL PRIVILEGES ON db.table FROM ALL
query. - There are no lifetime settings for privileges.
User Account
A user account is an access entity that allows to authorize someone in ClickHouse. A user account contains:
- Identification information.
- that define a scope of queries the user can execute.
- Assigned and default roles.
- Settings with their constraints applied by default at user login.
- Assigned settings profiles.
Privileges can be granted to a user account by the GRANT query or by assigning . To revoke privileges from a user, ClickHouse provides the REVOKE query. To list privileges for a user, use the statement.
Management queries:
Settings Applying
Settings can be configured differently: for a user account, in its granted roles and in settings profiles. At user login, if a setting is configured for different access entities, the value and constraints of this setting are applied as follows (from higher to lower priority):
- User account settings.
- The settings of default roles of the user account. If a setting is configured in some roles, then order of the setting application is undefined.
- The settings from settings profiles assigned to a user or to its default roles. If a setting is configured in some profiles, then order of setting application is undefined.
- Settings applied to all the server by default or from the default profile.
Role is a container for access entities that can be granted to a user account.
Role contains:
- Settings and constraints
- List of assigned roles
Management queries:
Privileges can be granted to a role by the GRANT query. To revoke privileges from a role ClickHouse provides the query.
Row Policy
Management queries:
Settings profile is a collection of settings. Settings profile contains settings and constraints, as well as a list of roles and/or users to which this profile is applied.
Management queries:
Quota
Quota limits resource usage. See .
Quota contains a set of limits for some durations, as well as a list of roles and/or users which should use this quota.
Management queries:
Setup a directory for configurations storage.
ClickHouse stores access entity configurations in the folder set in the access_control_path server configuration parameter.