-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ning Sun <[email protected]> Co-authored-by: Yiran <[email protected]>
- Loading branch information
1 parent
e6f2ef9
commit 6a6a8cf
Showing
27 changed files
with
219 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# LDAP User Provider | ||
|
||
:::tip NOTE | ||
|
||
**LDAP user provider is only available in GreptimeDB Enterprise.** | ||
|
||
::: | ||
|
||
## Configuration | ||
|
||
GreptimeDB can connect to an external LDAP server to authenticate users. Similar to [LDAP in PostgreSQL](https://www.postgresql.org/docs/current/auth-ldap.html), in GreptimeDB, LDAP authentication is | ||
operated in two modes: "simple bind" and "search bind", too. | ||
|
||
In the "simple bind" mode, GreptimeDB will bind to the "DN"(distinguished name) constructed as | ||
`{prefix}{username}{suffix}`. Typically, the `prefix` parameter is used to specify `cn=`, and the `suffix` is used to | ||
specify the remaining part of the DN. The `username`, of course, is provided by the client. | ||
|
||
Here's the configuration file example for the "simple bind" mode in GreptimeDB's LDAP user provider: | ||
|
||
```toml | ||
# Name or IP address of the LDAP server to connect to. | ||
server = "127.0.0.1" | ||
# Port number on LDAP server to connect to. | ||
port = 636 | ||
# Set to "ldap" to use LDAP, "ldaps" to use LDAPS. | ||
# The connection between GreptimeDB and the LDAP server starts as an initially unencrypted one, | ||
# then upgrades to TLS as the first action against the server, per the LDAPv3 standard ("StartTLS"). | ||
scheme = "ldaps" | ||
|
||
# The authentication mode to the LDAP server, either `bind = "simple"` or `bind = "search"`. | ||
[auth_mode] | ||
# The following options are used in simple bind mode only: | ||
bind = "simple" | ||
# String to prepend to the username when forming the DN to bind as, when doing simple bind authentication. | ||
prefix = "cn=" | ||
# String to append to the username when forming the DN to bind as, when doing simple bind authentication. | ||
suffix = ",dc=example,dc=com" | ||
``` | ||
|
||
In the "search bind" mode, GreptimeDB will first try to bind to the LDAP directory with a fixed username and password, | ||
which are set in the configuration file (`bind_dn` and `bind_passwd`), Then GreptimeDB performs a search for the user | ||
trying to log in to the database. The search will be performed over the subtree at `base_dn`, filtered by the | ||
`search_filter`, and will try to do an exact match of the attribute specified in `search_attribute`. Once the user has | ||
been found in this search, GreptimeDB re-binds to the directory as this user, using the password specified by the | ||
client, to verify that the login is correct. This method allows for significantly more flexibility in where the user | ||
objects are located in the directory, but will cause two additional requests to the LDAP server to be made. | ||
|
||
The following toml snippets show the configuration file example for the "search bind" mode in GreptimeDB's LDAP user | ||
provider. The common parts of `server`, `port`, and `scheme` as shown in the "simple bind" mode configuration file above | ||
are omitted: | ||
|
||
```toml | ||
[auth_mode] | ||
# The following options are used in search bind mode only: | ||
bind = "search" | ||
# Root DN to begin the search for the user in, when doing search bind authentication. | ||
base_dn = "ou=people,dc=example,dc=com" | ||
# DN of user to bind to the directory with to perform the search when doing search bind authentication. | ||
bind_dn = "cn=admin,dc=example,dc=com" | ||
# Password for user to bind to the directory with to perform the search when doing search bind authentication. | ||
bind_passwd = "secret" | ||
# Attribute to match against the username in the search when doing search bind authentication. | ||
# If no attribute is specified, the uid attribute will be used. | ||
search_attribute = "cn" | ||
# The search filter to use when doing search bind authentication. | ||
# Occurrences of "$username" will be replaced with the username. | ||
# This allows for more flexible search filters than search_attribute. | ||
search_filter = "(cn=$username)" | ||
``` | ||
|
||
## Use LDAP user provider in GreptimeDB | ||
|
||
To use the LDAP user provider, first config your LDAP authentication mode like above, then start GreptimeDB with the | ||
`--user-provider` parameter set to `ldap_user_provider:<path to your ldap configuration file>`. For example, if you have | ||
a configuration file `/home/greptimedb/ldap.toml`, you can start a GreptimeDB standalone server with the following | ||
command: | ||
|
||
```shell | ||
greptime standalone start --user-provider=ldap_user_provider:/home/greptimedb/ldap.toml | ||
``` | ||
|
||
Now you can create a connection to GreptimeDB using your LDAP user accounts. | ||
|
||
:::tip NOTE | ||
If you are using the MySQL CLI to connect to GreptimeDB that is configured with LDAP user provider, you need | ||
to specify the `--enable-cleartext-plugin` in the MySQL CLI. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Authentication | ||
|
||
Authentication occurs when a user attempts to connect to the database. In GreptimeDB, users are authenticated by "user | ||
provider"s. There are various implementations of user providers in GreptimeDB: | ||
|
||
- [Static user provider](./static.md): A simple built-in user provider implementation that finds users from a static | ||
file. | ||
- [LDAP user provider](./ldap.md): **Enterprise feature.** A user provider implementation that authenticates users against an external LDAP | ||
server. | ||
|
4 changes: 2 additions & 2 deletions
4
.../user-guide/deployments/authentication.md → ...uide/deployments/authentication/static.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...aurus-plugin-content-docs/current/user-guide/deployments/authentication/ldap.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# LDAP User Provider | ||
|
||
:::tip NOTE | ||
|
||
**LDAP user provider 是 GreptimeDB 企业版的功能。** | ||
|
||
::: | ||
|
||
## 配置 | ||
|
||
GreptimeDB 可以使用外部 LDAP 服务以验证用户。与 [PostgreSQL 中的 LDAP 机制相似](https://www.postgresql.org/docs/current/auth-ldap.html), 在 GreptimeDB 中,LDAP 鉴权也分为两种模式:"simple bind" 和 "search bind"。 | ||
|
||
在 "simple bind" 模式下,GreptimeDB 会构造一个格式为 `{prefix}{username}{suffix}` 的 "DN"(distinguished name) | ||
,并使用客户端传来的密码向 LDAP 服务发起”绑定 (bind)“。绑定的结果就是鉴权的结果。一个典型配置是,`prefix` 参数指定 `cn=`, | ||
`suffix` 用于指定 DN 的其余部分。`username` 将会被替换为客户端发来的用户名。 | ||
|
||
以下一个 LDAP user provider "simple bind" 模式的配置文件示例: | ||
|
||
```toml | ||
# LDAP 服务地址。 | ||
server = "127.0.0.1" | ||
# LDAP 服务端口。 | ||
port = 636 | ||
# 设置为 "ldap" 以使用 LDAP scheme,"ldaps" 以使用 LDAPS。 | ||
# GreptimeDB 和 LDAP 服务之间的连接一开始时是未加密的。连接建立后升级到 TLS。这是 LDAPv3 的 "StartTLS" 标准。 | ||
scheme = "ldaps" | ||
|
||
# LDAP 鉴权模式。`bind = "simple"` 和 `bind = "search"` 只能选择其一。 | ||
[auth_mode] | ||
# 以下配置仅在 simple bind 模式下使用: | ||
bind = "simple" | ||
# 当进行 simple bind 鉴权时,用于构造绑定 DN 的前缀。 | ||
prefix = "cn=" | ||
# 当进行 simple bind 鉴权时,用于构造绑定 DN 的后缀。 | ||
suffix = ",dc=example,dc=com" | ||
``` | ||
|
||
在 "search bind" 模式中,GreptimeDB 首先会使用配置文件中设置的固定用户名和密码(`bind_dn` 和 `bind_passwd`)尝试绑定到 LDAP | ||
目录。然后 GreptimeDB 会在 LDAP 目录中搜索尝试登录到数据库的用户。搜索将在 `base_dn` 下的子树中进行,由 `search_filter` | ||
过滤,并尝试对 `search_attribute` 中指定的属性进行精确匹配。一旦在搜索中找到用户,GreptimeDB | ||
会以此用户重新绑定到目录,使用客户端指定的密码,以验证登录是否正确。这种方法允许用户对象在 LDAP 目录中的位置更加灵活,但会导致向 | ||
LDAP 服务器发出两个额外的请求。 | ||
|
||
以下 toml 片段展示了 GreptimeDB LDAP user provider "search bind" 模式的配置文件示例。在上面的 "simple bind" 模式配置文件中显示的 | ||
`server`、`port` 和 `scheme` 的公共部分被省略了: | ||
|
||
```toml | ||
[auth_mode] | ||
# 以下配置仅在 search bind 模式下使用: | ||
bind = "search" | ||
# 进行 search bind 鉴权时,开始搜索用户的根 DN。 | ||
base_dn = "ou=people,dc=example,dc=com" | ||
# 进行 search bind 鉴权时,首先进行绑定的用户 DN。 | ||
bind_dn = "cn=admin,dc=example,dc=com" | ||
# 进行 search bind 鉴权时,首先进行绑定的用户密码。 | ||
bind_passwd = "secret" | ||
# 进行 search bind 鉴权时,用于匹配的用户属性。 | ||
# 如果未指定属性,则将使用 uid 属性。 | ||
search_attribute = "cn" | ||
# 进行 search bind 鉴权时,使用的搜索过滤器。 | ||
# "$username" 将被替换为客户端传来的用户名。 | ||
# 这允许比 search_attribute 更灵活的用户搜索。 | ||
search_filter = "(cn=$username)" | ||
``` | ||
|
||
## 在 GreptimeDB 中使用 LDAP User Provider | ||
|
||
要使用 LDAP User Provider,首先参照上文配置你的 LDAP 鉴权模式,然后在启动 GreptimeDB 时使用 `--user-provider` 参数,将其设置为 | ||
`ldap_user_provider:<ldap 配置文件路径>`。例如,如果你有一个配置文件是 `/home/greptimedb/ldap.toml`,你可以使用以下命令启动一个 | ||
standalone GreptimeDB: | ||
|
||
```shell | ||
greptime standalone start --user-provider=ldap_user_provider:/home/greptimedb/ldap.toml | ||
``` | ||
|
||
现在你就可以使用你的 LDAP 用户账户创建一个连接到 GreptimeDB 了。 | ||
|
||
:::tip 注意 | ||
如果你使用 MySQL CLI 连接到配置了 LDAP User Provider 的 GreptimeDB,你需要在 MySQL CLI 中指定 | ||
`--enable-cleartext-plugin`。 | ||
::: |
8 changes: 8 additions & 0 deletions
8
...s-plugin-content-docs/current/user-guide/deployments/authentication/overview.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 鉴权 | ||
|
||
当客户端尝试连接到数据库时,将会进行身份验证。GreptimeDB 通过 “user provider” 进行身份验证。GreptimeDB 中有多种 user | ||
provider 实现: | ||
|
||
- [Static user provider](./static.md):一个简单的内置 user provider 实现,从静态文件中查找用户。 | ||
- [LDAP user provider](./ldap.md):**企业版功能。**使用外部 LDAP 服务进行用户身份验证。 | ||
|
4 changes: 2 additions & 2 deletions
4
.../user-guide/deployments/authentication.md → ...uide/deployments/authentication/static.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.