Skip to main content

Built-in Authorization

Doris built-in authorization is based on the RBAC (Role-Based Access Control) model. Through the three-layer structure of "privilege to role to user", it restricts each user's access to and operations on resources such as nodes, Catalog, databases, tables, columns, Resource, and Workload Group based on the user's identity.

This document covers the core concepts, runtime mechanism, related SQL commands, and typical privilege planning scenarios of Doris built-in authorization.

Applicable Scenarios

ScenarioRecommended Approach
Cluster operations (administrator)Grant Admin_priv or Node_priv, and use the built-in operator / admin roles
Data development (create databases/tables, load data)Grant CREATE, DROP, ALTER, LOAD, SELECT privileges on specified databases/tables
Data query (read-only access)Grant Select_priv on specified databases/tables/columns
Multi-business multi-tenant shared clusterCreate a "business administrator" user with database-level Grant_priv for each business database, and let that user manage its own business users
Resource / workload isolationControl the use of Resource and Workload Group through Usage_priv
Sensitive field protection (such as phone number, ID number)Use column-level Select_priv, or combine with Data Access Control to configure row-level policies

Core Concepts

Doris authorization consists of the following three core entities:

  • Privilege: The operation permission acting on a specific resource object (such as read, write, modify).
  • Role: A set of privileges that can be granted to users.
  • User: The initiator of an operation, uniquely identified by user_name and host.

Privilege

The objects that privileges act on include nodes, Catalog, databases, tables, columns, Resource, and Workload Group. Different privileges represent different operation permissions.

All Privilege Items

PrivilegeObject TypeDescription
Admin_privGlobalSuper administrator privilege.
Node_privGlobalNode modification privilege. Includes operations such as adding, removing, and decommissioning FE, BE, and BROKER nodes.
Grant_privGlobal, Catalog, Db, Table, Resource, Workload GroupPrivilege modification privilege. Allows operations such as granting and revoking privileges, and adding, removing, or modifying users and roles.
When granting privileges to other users/roles: before version 2.1.2, the current user only needs the corresponding level of Grant_priv; from version 2.1.2 onward, the current user must also hold the privilege on the resource being granted.
When assigning a role to other users, the current user must hold the Global-level Grant_priv.
Select_privGlobal, Catalog, Db, Table, ColumnRead-only privilege on Catalog, databases, tables, and columns.
Load_privGlobal, Catalog, Db, TableWrite privilege on Catalog, databases, and tables. Includes Load, Insert, Delete, and so on.
Alter_privGlobal, Catalog, Db, TableModification privilege on Catalog, databases, and tables. Includes renaming databases/tables, adding/removing/modifying columns, and adding/removing partitions.
Create_privGlobal, Catalog, Db, TablePrivilege to create Catalog, databases, tables, and views.
Drop_privGlobal, Catalog, Db, TablePrivilege to drop Catalog, databases, tables, and views.
Usage_privResource, Workload GroupUsage privilege on Resource and Workload Group.
Show_view_privGlobal, Catalog, Db, TablePrivilege to execute SHOW CREATE VIEW.

Privilege Levels

The same privilege can be granted at different levels. The resource path specified in the GRANT statement determines the scope of the privilege.

LevelGrant Path ExampleScope
GlobalGRANT ... ON *.*.* TO user1Any database or table in any Catalog
CatalogGRANT ... ON ctl.*.* TO user1Any database or table in the specified Catalog
DatabaseGRANT ... ON ctl.db.* TO user1Any table in the specified database
TableGRANT ... ON ctl.db.tbl TO user1Any column in the specified table
ColumnGRANT Select_priv(col1,col2) ON ctl.db.tbl TO user1Specified columns of the specified table; currently column privileges support only Select_priv
RowDefined based on policies, see Data Access ControlControls the data rows accessible to the user
ResourceGRANT USAGE_PRIV ON RESOURCE '%' TO user1Use of Resource; supports only Usage_priv and Grant_priv
Workload GroupGRANT USAGE_PRIV ON WORKLOAD GROUP '%' TO user1Use of Workload Group; supports only Usage_priv and Grant_priv
tip

Admin_priv can only be granted or revoked at the Global level.

Role

A role is a set of privileges. After a user is assigned a role, the user automatically inherits all privileges of that role. Subsequent changes to the role's privileges are also synchronized to all users holding that role.

Built-in Roles

Doris creates the following two built-in roles by default:

Built-in RoleDefault PrivilegesTypical Use
operatorAdmin_priv + Node_privCluster operations, node modification
adminAdmin_privBusiness management, data management

Custom Roles

You can create named roles through CREATE ROLE, combine commonly used privileges, and grant them to users in batch. This makes unified management and privilege revocation easier.

User

In Doris, a user_identity uniquely identifies a user. A user_identity consists of two parts:

  • user_name: The user name.
  • host: The host address from which the user client connects.

Authorization Mechanism

The Doris privilege system is based on the RBAC model. Users are associated with roles, and roles are associated with privileges. A user holds privileges indirectly through roles.

┌────────┐        ┌────────┐         ┌────────┐
│ user1 ├────┬───► role1 ├────┬────► priv1 │
└────────┘ │ └────────┘ │ └────────┘
│ │
│ │
│ ┌────────┐ │
│ │ role2 ├────┤
┌────────┐ │ └────────┘ │ ┌────────┐
│ user2 ├────┘ │ ┌─► priv2 │
└────────┘ │ │ └────────┘
┌────────┐ │ │
┌──────► role3 ├────┘ │
│ └────────┘ │
│ │
│ │
┌────────┐ │ ┌────────┐ │ ┌────────┐
│ userN ├─┴──────► roleN ├───────┴─► privN │
└────────┘ └────────┘ └────────┘

As shown in the diagram above:

  • Both user1 and user2 hold the priv1 privilege through role1.
  • userN holds the priv1 privilege through role3, and holds the priv2 and privN privileges through roleN. Therefore, userN holds the priv1, priv2, and privN privileges at the same time.

Privilege Inheritance and Revocation Rules

  • When a role is dropped, the users holding that role automatically lose all privileges of that role.
  • When a user is unassigned from a role, the user automatically loses all privileges of that role.
  • When the privileges of a role are added or removed, the privileges of all users holding that role change synchronously.

Notes

  • For convenience, Doris supports granting privileges directly to users. In the underlying implementation, a dedicated default role is created for each user. Granting privileges directly to a user actually grants the privileges to this default role.
  • The default role cannot be dropped or assigned to other users. When a user is dropped, its default role is also dropped automatically.
Operation CategoryCommand
Grant / assign roleGRANT
Revoke / unassign roleREVOKE
Create roleCREATE ROLE
Drop roleDROP ROLE
Alter roleALTER ROLE
View current user privilegesSHOW GRANTS
View all user privilegesSHOW ALL GRANTS
View created rolesSHOW ROLES
View all supported privilege itemsSHOW PRIVILEGES

Best Practices

The following are two typical scenarios for using the Doris privilege system.

Scenario 1: Role-Based Division of Duties in a Single-Business Cluster

The users of a Doris cluster are divided into administrators (Admin), development engineers (RD), and clients (Client):

  • Administrator: Holds all privileges of the entire cluster, and is responsible for cluster setup, node management, and so on.
  • Development engineer (RD): Responsible for business modeling, including creating databases and tables, loading and modifying data.
  • Client: Accesses various databases and tables to retrieve data.

Recommended authorization plan:

  • Administrator: Grant Admin_priv or global Grant_priv.
  • RD: Grant Create_priv, Drop_priv, Alter_priv, Load_priv, and Select_priv on any or specified databases/tables.
  • Client: Grant Select_priv on any or specified databases/tables.

You can create different roles to simplify batch authorization for multiple users.

Scenario 2: Delegated Management in a Multi-Business Cluster

A single cluster hosts multiple businesses. Each business uses one or more databases, and each business needs to manage its own users.

Recommended authorization plan: The administrator creates a "business administrator" user for each business database, granting that user the database-level Grant_priv on the corresponding database. This user can only grant privileges to others within the scope of the authorized database, which achieves privilege isolation and self-management between businesses.