Skip to content

Commit e2a7a72

Browse files
authored
[doc] add LDAP default roles docs (#3697)
## Related PR - Code PR: apache/doris#63411 ## Versions - [x] dev - [ ] 4.x - [ ] 3.x - [ ] 2.1 ## Languages - [x] Chinese - [x] English ## Summary Adds documentation for `ldap_default_roles`, which allows Doris to grant configured default roles to every LDAP-authenticated user. The update explains: 1. How `ldap_default_roles` differs from the built-in `ldapDefaultRole`. 2. How default LDAP roles are merged with LDAP group roles and existing Doris user privileges. 3. That roles configured in `ldap_default_roles` must already exist in Doris. 4. How to configure `ldap_default_roles` in `ldap.conf`. 5. How to update `ldap_default_roles` online with `ADMIN SET FRONTEND CONFIG`. 6. That online updates of `ldap_default_roles` refresh the LDAP user cache automatically. ## Files - `docs/admin-manual/auth/authentication/ldap.md` - `i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/auth/authentication/ldap.md`
1 parent bd36eea commit e2a7a72

2 files changed

Lines changed: 122 additions & 10 deletions

File tree

  • docs/admin-manual/auth/authentication
  • i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/auth/authentication

docs/admin-manual/auth/authentication/ldap.md

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"LDAP group authorization",
1111
"unified authentication",
1212
"ldap.conf configuration",
13+
"ldap_default_roles",
1314
"MysqlClearPasswordPlugin",
1415
"ldap_admin_password",
1516
"ldap_use_ssl",
@@ -25,6 +26,7 @@ Apache Doris supports integration with third-party LDAP services, so the existin
2526

2627
- **Authentication login**: Use the LDAP password instead of the Doris password for identity authentication.
2728
- **Group authorization**: Map LDAP `group` to Doris `role` to achieve unified privilege management.
29+
- **Default role authorization**: Grant configured Doris roles to every LDAP-authenticated user without putting all users into one LDAP group.
2830

2931
<!-- Knowledge type: Architecture decision -->
3032
<!-- Applicable scenario: Integrating enterprise unified identity / centralized privilege management -->
@@ -35,6 +37,7 @@ Apache Doris supports integration with third-party LDAP services, so the existin
3537
| --- | --- |
3638
| Enterprise unified identity authentication | An LDAP/AD account system already exists, and you want Doris users to reuse it directly without creating accounts again in Doris |
3739
| Centralized privilege management | Manage role members through LDAP groups; adjust LDAP group members to batch-adjust Doris privileges |
40+
| Baseline privileges for LDAP users | Grant the same Doris roles to all LDAP-authenticated users through configuration, while still keeping LDAP group authorization |
3841
| Temporary access | Users that exist only in LDAP can log in to Doris as temporary users based on LDAP group privileges |
3942
| Encrypted channel | Encryption is required for the connection between Doris FE and the LDAP server (LDAPS) |
4043

@@ -87,6 +90,7 @@ In LDAP, data is organized in a tree structure. The following is a typical LDAP
8790
3. **Configure the client**: Enable the cleartext password plugin in the MySQL Client or JDBC Client to send the LDAP password.
8891
4. **(Optional) Enable LDAPS**: Encrypt the channel between FE and LDAP.
8992
5. **(Optional) Configure group authorization**: Create `role` in Doris with the same name as the LDAP groups and grant privileges.
93+
6. **(Optional) Configure default roles**: Grant baseline Doris roles to all LDAP-authenticated users through `ldap_default_roles`.
9094

9195
## Step 1: Configure Doris FE
9296

@@ -113,6 +117,7 @@ ldap_admin_name = uid=admin,o=emr
113117
ldap_user_basedn = ou=people,o=emr
114118
ldap_user_filter = (&(uid={login}))
115119
ldap_group_basedn = ou=group,o=emr
120+
ldap_default_roles = ldap_readonly,ldap_query_user
116121
```
117122

118123
The configuration items are explained below:
@@ -126,6 +131,7 @@ The configuration items are explained below:
126131
| `ldap_user_basedn` | The base `dn` for user search |
127132
| `ldap_user_filter` | User match filter. `{login}` is replaced with the login user name |
128133
| `ldap_group_basedn` | The base `dn` for group search, used for group authorization |
134+
| `ldap_default_roles` | Optional. Comma-separated Doris roles granted to every LDAP-authenticated user. These roles are added in addition to LDAP group roles |
129135

130136
:::tip
131137
To enable LDAPS (encrypted connection to the LDAP server), see the [LDAPS (Encrypted Connection)](#ldaps-encrypted-connection) section below.
@@ -235,8 +241,8 @@ After LDAP is enabled, the login behavior under different user states is as foll
235241
236242
- The temporary account is valid only for the current connection and is automatically destroyed after the connection is closed.
237243
- Doris does not create persistent user metadata for a temporary user.
238-
- The privileges of a temporary user are determined by LDAP group authorization (see the "Group Authorization" section below).
239-
- If the temporary user has no corresponding group privileges, it has the `select_priv` privilege on `information_schema` by default.
244+
- The privileges of a temporary user are determined by LDAP group authorization and `ldap_default_roles` (see the "Group Authorization" and "Default Roles for LDAP Users" sections below).
245+
- If the temporary user has no corresponding group privileges or configured default roles, it has the `select_priv` privilege on `information_schema` by default.
240246
241247
:::
242248
@@ -265,7 +271,7 @@ mysql -hDoris_HOST -PDoris_PORT -ujack -p 123456
265271
266272
- LDAP user attributes: `uid: jack`, password: `abcdef`
267273
268-
Log in with the LDAP password. Doris automatically creates the temporary user `jack@'%'` and logs in. The temporary user has the basic privilege `DatabasePrivs`: `Select_priv`, and is automatically destroyed after the connection is closed:
274+
Log in with the LDAP password. Doris automatically creates the temporary user `jack@'%'` and logs in. The temporary user receives LDAP group roles and configured default roles if they are available. If no matching roles are available, it has the basic privilege `DatabasePrivs`: `Select_priv`, and is automatically destroyed after the connection is closed:
269275
270276
```sql
271277
mysql -hDoris_HOST -PDoris_PORT -ujack -p abcdef
@@ -290,6 +296,7 @@ LDAP group authorization maps LDAP `group` to Doris `role`, providing centralize
290296
291297
- If the `dn` of an LDAP user appears in the `member` attribute of an LDAP group node, Doris considers the user to belong to that group.
292298
- When the user logs in, Doris automatically grants the user the `role` privileges corresponding to the LDAP groups it belongs to.
299+
- If `ldap_default_roles` is configured, Doris also grants those default roles to the user.
293300
- After the user logs out, Doris automatically revokes these `role` privileges.
294301
295302
:::caution Prerequisites
@@ -302,9 +309,9 @@ The final privileges of the logged-in user depend on its state in LDAP and Doris
302309
303310
| LDAP user | Doris user | Final privileges |
304311
| --------- | ---------- | ---------------- |
305-
| Exists | Exists | LDAP group privileges + Doris user privileges |
312+
| Exists | Exists | LDAP group privileges + configured default roles + Doris user privileges |
306313
| Does not exist | Exists | Doris user privileges |
307-
| Exists | Does not exist | LDAP group privileges |
314+
| Exists | Does not exist | LDAP group privileges + configured default roles |
308315
309316
### Group Name Mapping Rules
310317
@@ -331,6 +338,50 @@ Suppose user jack belongs to the LDAP groups `doris_rd`, `doris_qa`, and `doris_
331338
332339
:::
333340
341+
## Default Roles for LDAP Users
342+
343+
<!-- Knowledge type: Configuration parameters -->
344+
<!-- Applicable scenario: Granting baseline Doris privileges to all LDAP-authenticated users -->
345+
346+
`ldap_default_roles` is used to grant baseline Doris roles to every LDAP-authenticated user. It is useful when all LDAP users should have the same basic privileges, but maintaining a dedicated LDAP group that contains all LDAP users is impractical.
347+
348+
`ldap_default_roles` does not replace LDAP group authorization. When an LDAP user logs in, Doris merges all of the following privileges:
349+
350+
- Doris roles mapped from the user's LDAP groups.
351+
- Doris roles configured in `ldap_default_roles`.
352+
- Existing privileges of the Doris user, if the same account also exists in Doris.
353+
- The built-in `ldapDefaultRole`, which provides `select_priv` on `information_schema`.
354+
355+
:::caution Prerequisites
356+
Roles listed in `ldap_default_roles` must already exist in Doris. If a configured role does not exist, Doris ignores that role and logs a warning.
357+
:::
358+
359+
### Configure Default Roles
360+
361+
Create the roles and grant privileges to them:
362+
363+
```sql
364+
CREATE ROLE ldap_readonly;
365+
CREATE ROLE ldap_query_user;
366+
367+
GRANT SELECT_PRIV ON internal.example_db.* TO ROLE 'ldap_readonly';
368+
GRANT SELECT_PRIV ON internal.example_db.example_table TO ROLE 'ldap_query_user';
369+
```
370+
371+
Configure the roles in `fe/conf/ldap.conf`:
372+
373+
```text
374+
ldap_default_roles = ldap_readonly,ldap_query_user
375+
```
376+
377+
You can also update the value online:
378+
379+
```sql
380+
ADMIN SET FRONTEND CONFIG ("ldap_default_roles" = "ldap_readonly,ldap_query_user");
381+
```
382+
383+
After `ldap_default_roles` is updated online, Doris refreshes the LDAP user cache automatically so later LDAP logins can use the new default roles.
384+
334385
## LDAPS (Encrypted Connection)
335386
336387
<!-- Knowledge type: Configuration parameters -->
@@ -395,6 +446,8 @@ In the following scenarios, you may need to manually refresh the cache so that t
395446
- User or group information in the LDAP service has been modified.
396447
- The `Role` privileges corresponding to LDAP user groups in Doris have been modified.
397448
449+
Online updates to `ldap_default_roles` refresh the LDAP user cache automatically. You do not need to run `refresh ldap` only for this configuration change.
450+
398451
You can refresh the cache with the `refresh ldap` statement. For details, see [REFRESH-LDAP](../../../sql-manual/sql-statements/account-management/REFRESH-LDAP).
399452
400453
## Known Limitations
@@ -411,6 +464,8 @@ You can refresh the cache with the `refresh ldap` statement. For details, see [R
411464
412465
After logging in to Doris with an LDAP user, run `show grants;` to view all roles of the current user. Among them, `ldapDefaultRole` is the default role that every LDAP user has.
413466
467+
`ldapDefaultRole` is a built-in temporary role that provides `select_priv` on `information_schema`. It is different from roles configured in `ldap_default_roles`.
468+
414469
### Q: An LDAP user has fewer roles in Doris than expected. How do I troubleshoot?
415470
416471
Check the following items one by one:
@@ -419,6 +474,7 @@ Check the following items one by one:
419474
2. Check whether the expected `group` is located under the organizational structure corresponding to `ldap_group_basedn`.
420475
3. Check whether the expected `group` contains the `member` attribute.
421476
4. Check whether the `member` attribute of the expected `group` contains the `dn` of the current user.
477+
5. If the missing role is configured in `ldap_default_roles`, check whether the role name is spelled correctly and whether the role exists in Doris.
422478
423479
### Q: LDAPS connection fails. How do I troubleshoot?
424480

i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/auth/authentication/ldap.md

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"LDAP 组授权",
1111
"统一身份验证",
1212
"ldap.conf 配置",
13+
"ldap_default_roles",
1314
"MysqlClearPasswordPlugin",
1415
"ldap_admin_password",
1516
"ldap_use_ssl",
@@ -25,6 +26,7 @@ Apache Doris 支持接入第三方 LDAP 服务,将企业内已有的账号体
2526

2627
- **验证登录**:使用 LDAP 密码替代 Doris 密码进行身份认证。
2728
- **组授权**:将 LDAP 中的 `group` 映射为 Doris 中的 `role`,实现统一权限管理。
29+
- **默认角色授权**:为所有通过 LDAP 认证的用户授予配置好的 Doris 角色,无需将所有用户维护到同一个 LDAP 组中。
2830

2931
<!-- 知识类型: 架构选型决策 -->
3032
<!-- 适用场景: 接入企业统一身份 / 集中权限管理 -->
@@ -35,6 +37,7 @@ Apache Doris 支持接入第三方 LDAP 服务,将企业内已有的账号体
3537
| --- | --- |
3638
| 企业统一身份认证 | 已有 LDAP/AD 账号体系,希望 Doris 用户直接复用,无需在 Doris 中重复创建账号 |
3739
| 集中化权限管理 | 通过 LDAP 组管理角色成员,调整 LDAP 组成员即可批量调整 Doris 权限 |
40+
| LDAP 用户基础权限 | 通过配置为所有 LDAP 认证用户授予相同的 Doris 角色,同时保留 LDAP 组授权 |
3841
| 临时访问 | 仅在 LDAP 中存在的用户,可基于 LDAP 组权限以临时用户身份登录 Doris |
3942
| 加密链路 | 需要 Doris FE 与 LDAP 服务器之间的连接加密(LDAPS) |
4043

@@ -87,6 +90,7 @@ Apache Doris 支持接入第三方 LDAP 服务,将企业内已有的账号体
8790
3. **配置客户端**:MySQL Client 或 JDBC Client 启用明文密码插件,以便发送 LDAP 密码。
8891
4. **(可选)启用 LDAPS**:加密 FE 与 LDAP 之间的链路。
8992
5. **(可选)配置组授权**:在 Doris 中创建与 LDAP 组同名的 `role` 并授权。
93+
6. **(可选)配置默认角色**:通过 `ldap_default_roles` 为所有 LDAP 认证用户授予基础 Doris 角色。
9094

9195
## 第一步:配置 Doris FE
9296

@@ -113,6 +117,7 @@ ldap_admin_name = uid=admin,o=emr
113117
ldap_user_basedn = ou=people,o=emr
114118
ldap_user_filter = (&(uid={login}))
115119
ldap_group_basedn = ou=group,o=emr
120+
ldap_default_roles = ldap_readonly,ldap_query_user
116121
```
117122

118123
各配置项含义如下:
@@ -126,6 +131,7 @@ ldap_group_basedn = ou=group,o=emr
126131
| `ldap_user_basedn` | 用户搜索的基准 `dn` |
127132
| `ldap_user_filter` | 用户匹配过滤器,`{login}` 会被替换为登录用户名 |
128133
| `ldap_group_basedn` | 组搜索的基准 `dn`,用于组授权 |
134+
| `ldap_default_roles` | 可选。为所有 LDAP 认证用户授予的 Doris 角色,多个角色用逗号分隔。这些角色会在 LDAP 组角色之外额外授予 |
129135

130136
:::tip
131137
如需启用 LDAPS(加密连接至 LDAP 服务器),请参阅下文 [LDAPS(加密连接)](#ldaps加密连接) 章节。
@@ -235,8 +241,8 @@ LDAP 验证登录是指通过 LDAP 服务进行密码验证,以补充 Doris
235241
236242
- 临时账户仅对当前连接有效,连接断开后自动销毁。
237243
- Doris 不会为临时用户创建持久化的用户元数据。
238-
- 临时用户的权限由 LDAP 组授权决定(详见下文"组授权"章节)。
239-
- 如果临时用户没有对应的组权限,则默认拥有 `information_schema``select_priv` 权限。
244+
- 临时用户的权限由 LDAP 组授权和 `ldap_default_roles` 决定(详见下文"组授权""LDAP 用户默认角色"章节)。
245+
- 如果临时用户没有对应的组权限,也没有配置的默认角色,则默认拥有 `information_schema``select_priv` 权限。
240246
241247
:::
242248
@@ -265,7 +271,7 @@ mysql -hDoris_HOST -PDoris_PORT -ujack -p 123456
265271
266272
- LDAP 用户属性:`uid: jack`,密码:`abcdef`
267273
268-
使用 LDAP 密码登录,Doris 自动创建临时用户 `jack@'%'` 并登录。临时用户具有基本权限 `DatabasePrivs``Select_priv`,断开连接后自动销毁:
274+
使用 LDAP 密码登录,Doris 自动创建临时用户 `jack@'%'` 并登录。如果存在可用角色,临时用户会获得 LDAP 组角色和配置的默认角色。如果没有匹配角色,则具有基本权限 `DatabasePrivs``Select_priv`,断开连接后自动销毁:
269275
270276
```sql
271277
mysql -hDoris_HOST -PDoris_PORT -ujack -p abcdef
@@ -290,6 +296,7 @@ LDAP 组授权是将 LDAP 中的 `group` 映射到 Doris 中的 `role`,从而
290296
291297
- 如果 LDAP 用户的 `dn` 出现在某个 LDAP 组节点的 `member` 属性中,则 Doris 认为该用户属于该组。
292298
- 用户登录时,Doris 自动授予其所属 LDAP 组对应的 `role` 权限。
299+
- 如果配置了 `ldap_default_roles`,Doris 也会为该用户授予这些默认角色。
293300
- 用户退出登录后,Doris 自动撤销这些 `role` 权限。
294301
295302
:::caution 前提条件
@@ -302,9 +309,9 @@ LDAP 组授权是将 LDAP 中的 `group` 映射到 Doris 中的 `role`,从而
302309
303310
| LDAP 用户 | Doris 用户 | 最终权限 |
304311
| --------- | ---------- | ------------------------------ |
305-
| 存在 | 存在 | LDAP 组权限 + Doris 用户权限 |
312+
| 存在 | 存在 | LDAP 组权限 + 配置的默认角色 + Doris 用户权限 |
306313
| 不存在 | 存在 | Doris 用户权限 |
307-
| 存在 | 不存在 | LDAP 组权限 |
314+
| 存在 | 不存在 | LDAP 组权限 + 配置的默认角色 |
308315
309316
### 组名映射规则
310317
@@ -331,6 +338,50 @@ member: uid=jack,ou=aidp,dc=domain,dc=com
331338
332339
:::
333340
341+
## LDAP 用户默认角色
342+
343+
<!-- 知识类型: 配置参数 -->
344+
<!-- 适用场景: 为所有 LDAP 认证用户授予基础 Doris 权限 -->
345+
346+
`ldap_default_roles` 用于为所有通过 LDAP 认证的用户授予基础 Doris 角色。当所有 LDAP 用户都需要一组相同的基础权限,但不适合在 LDAP 中维护一个包含所有用户的专用组时,可以使用该配置。
347+
348+
`ldap_default_roles` 不会替代 LDAP 组授权。LDAP 用户登录后,Doris 会合并以下权限:
349+
350+
- 用户所属 LDAP 组映射得到的 Doris 角色。
351+
- `ldap_default_roles` 中配置的 Doris 角色。
352+
- 如果 Doris 中也存在同名账号,则保留该 Doris 用户已有的权限。
353+
- 内置的 `ldapDefaultRole`,用于提供 `information_schema` 上的 `select_priv` 权限。
354+
355+
:::caution 前提条件
356+
`ldap_default_roles` 中列出的角色必须已经存在于 Doris 中。如果配置的角色不存在,Doris 会忽略该角色并记录 warning 日志。
357+
:::
358+
359+
### 配置默认角色
360+
361+
先创建角色并为角色授权:
362+
363+
```sql
364+
CREATE ROLE ldap_readonly;
365+
CREATE ROLE ldap_query_user;
366+
367+
GRANT SELECT_PRIV ON internal.example_db.* TO ROLE 'ldap_readonly';
368+
GRANT SELECT_PRIV ON internal.example_db.example_table TO ROLE 'ldap_query_user';
369+
```
370+
371+
`fe/conf/ldap.conf` 中配置角色列表:
372+
373+
```text
374+
ldap_default_roles = ldap_readonly,ldap_query_user
375+
```
376+
377+
也可以在线修改该配置:
378+
379+
```sql
380+
ADMIN SET FRONTEND CONFIG ("ldap_default_roles" = "ldap_readonly,ldap_query_user");
381+
```
382+
383+
在线修改 `ldap_default_roles` 后,Doris 会自动刷新 LDAP 用户缓存,后续 LDAP 登录即可使用新的默认角色。
384+
334385
## LDAPS(加密连接)
335386
336387
<!-- 知识类型: 配置参数 -->
@@ -395,6 +446,8 @@ JAVA_OPTS_FOR_JDK_17 = "-Djavax.net.ssl.trustStore=/path/to/your/cacerts -Djavax
395446
- 修改了 LDAP 服务中的用户或组信息。
396447
- 修改了 Doris 中 LDAP 用户组对应的 `Role` 权限。
397448
449+
在线修改 `ldap_default_roles` 时,Doris 会自动刷新 LDAP 用户缓存。仅修改该配置时,不需要额外执行 `refresh ldap`
450+
398451
可以通过 `refresh ldap` 语句刷新缓存,详细查看 [REFRESH-LDAP](../../../sql-manual/sql-statements/account-management/REFRESH-LDAP)。
399452
400453
## 已知限制
@@ -411,6 +464,8 @@ JAVA_OPTS_FOR_JDK_17 = "-Djavax.net.ssl.trustStore=/path/to/your/cacerts -Djavax
411464
412465
使用 LDAP 用户登录 Doris 后,执行 `show grants;` 即可查看当前用户的所有角色。其中 `ldapDefaultRole` 是每个 LDAP 用户都拥有的默认角色。
413466
467+
`ldapDefaultRole` 是 Doris 内置的临时角色,用于提供 `information_schema` 上的 `select_priv` 权限。它与 `ldap_default_roles` 中配置的角色不是同一个概念。
468+
414469
### Q: LDAP 用户在 Doris 中的角色比预期少,如何排查?
415470
416471
按以下步骤逐项检查:
@@ -419,6 +474,7 @@ JAVA_OPTS_FOR_JDK_17 = "-Djavax.net.ssl.trustStore=/path/to/your/cacerts -Djavax
419474
2. 检查预期的 `group` 是否位于 `ldap_group_basedn` 对应的组织结构下。
420475
3. 检查预期的 `group` 是否包含 `member` 属性。
421476
4. 检查预期 `group``member` 属性中是否包含当前用户的 `dn`
477+
5. 如果缺少的是 `ldap_default_roles` 中配置的角色,检查角色名是否拼写正确,以及该角色是否已经在 Doris 中创建。
422478
423479
### Q: LDAPS 连接失败,如何排查?
424480

0 commit comments

Comments
 (0)