Skip to content

Commit e125556

Browse files
killme2008Copilot
andauthored
docs: add user permission docs (#2147)
Signed-off-by: Dennis Zhuang <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 23f56ed commit e125556

File tree

2 files changed

+118
-10
lines changed
  • docs/user-guide/deployments-administration/authentication
  • i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/authentication

2 files changed

+118
-10
lines changed

docs/user-guide/deployments-administration/authentication/static.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,79 @@ GreptimeDB offers a simple built-in mechanism for authentication, allowing users
99

1010
## Standalone Mode
1111

12-
GreptimeDB reads the user and password on each line using `=` as a separator, just like a command-line config.
13-
For example, create a file with the following content:
12+
GreptimeDB reads the user configuration from a file where each line defines a user with their password and optional permission mode.
13+
14+
### Basic Configuration
15+
16+
The basic format uses `=` as a separator between username and password:
1417

1518
```
1619
greptime_user=greptime_pwd
1720
alice=aaa
1821
bob=bbb
1922
```
2023

21-
then start server with `--user-provider` parameter:
24+
Users configured this way have full read-write access by default.
25+
26+
### Permission Modes
27+
28+
You can optionally specify permission modes to control user access levels. The format is:
29+
30+
```
31+
username:permission_mode=password
32+
```
33+
34+
Available permission modes:
35+
- `rw` or `readwrite` - Full read and write access (default when not specified)
36+
- `ro` or `readonly` - Read-only access
37+
- `wo` or `writeonly` - Write-only access
38+
39+
Example configuration with mixed permission modes:
40+
41+
```
42+
admin=admin_pwd
43+
alice:readonly=aaa
44+
bob:writeonly=bbb
45+
viewer:ro=viewer_pwd
46+
editor:rw=editor_pwd
47+
```
48+
49+
In this configuration:
50+
- `admin` has full read-write access (default)
51+
- `alice` has read-only access
52+
- `bob` has write-only access
53+
- `viewer` has read-only access
54+
- `editor` has explicitly set read-write access
55+
56+
### Starting the Server
57+
58+
Start the server with the `--user-provider` parameter and set it to `static_user_provider:file:<path_to_file>` (replace `<path_to_file>` with the path to your user configuration file):
2259

2360
```shell
2461
./greptime standalone start --user-provider=static_user_provider:file:<path_to_file>
2562
```
2663

27-
Now, user `alice` with password `aaa` and user `bob` with password `bbb` are loaded into GreptimeDB's memory. You can create a connection to GreptimeDB using these user accounts.
64+
The users and their permissions will be loaded into GreptimeDB's memory. You can create connections to GreptimeDB using these user accounts with their respective access levels enforced.
65+
66+
:::tip Note
67+
When using `static_user_provider:file`, the file’s contents are loaded at startup. Changes or additions to the file have no effect while the database is running.
68+
:::
69+
70+
### Dynamic File Reloading
71+
72+
If you need to update user credentials without restarting the server, you can use the `watch_file_user_provider` instead of `static_user_provider:file`. This provider monitors the credential file for changes and automatically reloads it:
73+
74+
```shell
75+
./greptime standalone start --user-provider=watch_file_user_provider:<path_to_file>
76+
```
77+
78+
The watch file provider:
79+
- Uses the same file format as the static file provider
80+
- Automatically detects file modifications and reloads credentials
81+
- Allows adding, removing, or modifying users without server restart
82+
- If the file is temporarily unavailable or invalid, it keeps the last valid configuration
2883

29-
Note: The content of the file is loaded into the database while starting up. Modifying or appending the file won't take effect while the database is up and running.
84+
This is particularly useful in production environments where you need to manage user access dynamically.
3085

3186
## Kubernetes Cluster
3287

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/authentication/static.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,80 @@ GreptimeDB 提供了简单的内置身份验证机制,允许你配置一个固
99

1010
## 单机模式
1111

12-
GreptimeDB 使用 `=` 作为分隔符,读取文件内每行中的用户和密码。
13-
例如在文件中添加以下内容:
12+
GreptimeDB 从配置文件中读取用户配置,每行定义一个用户及其密码和可选的权限模式。
13+
14+
### 基本配置
15+
16+
基本格式使用 `=` 作为用户名和密码之间的分隔符:
1417

1518
```
1619
greptime_user=greptime_pwd
1720
alice=aaa
1821
bob=bbb
1922
```
2023

21-
接下来在启动服务端时添加 `--user-provider` 参数:
24+
以这种方式配置的用户默认拥有完整的读写权限。
25+
26+
### 权限模式
27+
28+
你可以选择性地指定权限模式来控制用户的访问级别。格式为:
29+
30+
```
31+
username:permission_mode=password
32+
```
33+
34+
可用的权限模式:
35+
- `rw``readwrite` - 完整的读写权限(未指定时的默认值)
36+
- `ro``readonly` - 只读权限
37+
- `wo``writeonly` - 只写权限
38+
39+
混合权限模式的配置示例:
40+
41+
```
42+
admin=admin_pwd
43+
alice:readonly=aaa
44+
bob:writeonly=bbb
45+
viewer:ro=viewer_pwd
46+
editor:rw=editor_pwd
47+
```
48+
49+
在此配置中:
50+
- `admin` 拥有完整的读写权限(默认)
51+
- `alice` 拥有只读权限
52+
- `bob` 拥有只写权限
53+
- `viewer` 拥有只读权限
54+
- `editor` 明确设置了读写权限
55+
56+
### 启动服务器
57+
58+
在启动服务端时,需添加 `--user-provider` 参数,并将其设置为 `static_user_provider:file:<path_to_file>`(请将 `<path_to_file>` 替换为你的用户配置文件路径):
2259

2360
```shell
2461
./greptime standalone start --user-provider=static_user_provider:file:<path_to_file>
2562
```
2663

27-
这样,用户 `alice``bob` 的账户信息就会被加载到 GreptimeDB 中。你可以使用这些用户连接 GreptimeDB。
64+
用户及其权限将被载入 GreptimeDB 的内存。使用这些用户账户连接至 GreptimeDB 时,系统会严格执行相应的访问权限控制
2865

2966
:::tip 注意
30-
文件的内容只会在启动时被加载到数据库中,在数据库运行时修改或追加的内容不会生效。
67+
`static_user_provider:file` 模式下,文件的内容只会在启动时被加载到数据库中,在数据库运行时修改或追加的内容不会生效。
3168
:::
3269

70+
### 动态文件重载
71+
72+
如果你需要在不重启服务器的情况下更新用户凭证,可以使用 `watch_file_user_provider` 替代 `static_user_provider:file`。该 provider 会监控凭证文件的变化并自动重新加载:
73+
74+
```shell
75+
./greptime standalone start --user-provider=watch_file_user_provider:<path_to_file>
76+
```
77+
78+
`watch_file_user_provider`的特点:
79+
- 使用与 `static_user_provider:file` 相同的文件格式
80+
- 自动检测文件修改并重新加载凭证
81+
- 允许在不重启服务器的情况下添加、删除或修改用户
82+
- 如果文件临时不可用或无效,会保持上次有效的配置
83+
84+
这在需要动态管理用户访问的生产环境中特别有用。
85+
3386
## Kubernetes 集群
3487

3588
你可以在 `values.yaml` 文件中配置鉴权用户。

0 commit comments

Comments
 (0)