You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/deployments-administration/authentication/static.md
+60-5Lines changed: 60 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,24 +9,79 @@ GreptimeDB offers a simple built-in mechanism for authentication, allowing users
9
9
10
10
## Standalone Mode
11
11
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:
14
17
15
18
```
16
19
greptime_user=greptime_pwd
17
20
alice=aaa
18
21
bob=bbb
19
22
```
20
23
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):
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:
- 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
28
83
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.
Copy file name to clipboardExpand all lines: i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/authentication/static.md
0 commit comments