Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldap and improve query by tag index #711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 39 additions & 41 deletions docs-2.0/7.data-security/1.authentication/4.ldap.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
<!--
# 使用OpenLDAP进行身份验证
# OpenLDAP authentication

本文介绍如何将Nebula Graph连接到OpenLDAP服务器,使用OpenLDAP中定义的DN(Distinguished Name)和密码进行身份验证。
This topic introduces how to connect Nebula Graph to the OpenLDAP server and use the DN (Distinguished Name) and password defined in OpenLDAP for authentication.

!!! enterpriseonly

仅企业版支持本功能。
This feature is supported by the Enterprise Edition only.

## 认证方式
## Authentication method

启用OpenLDAP身份验证后,输入用户的账号和密码登录Nebula Graph时,Nebula Graph会在Meta服务中查找登录账号是否存在,如果账号存在,再根据认证方式去OpenLDAP中找到对应的DN,验证密码。
After the OpenLDAP authentication is enabled and users log into Nebula Graph with the account and password, Nebula Graph checks whether the login account exists in the Meta service. If the account exists, Nebula Graph finds the corresponding DN in OpenLDAP according to the authentication method and verifies the password.

OpenLDAP支持的认证方式有两种:简单绑定认证和搜索绑定认证。
OpenLDAP supports two authentication methods: simple bind authentication (SimpleBindAuth) and search bind authentication (SearchBindAuth).

### 简单绑定认证(SimpleBindAuth
### SimpleBindAuth

简单绑定认证会根据登录账号和Graph服务配置信息,拼接成OpenLDAP可以识别的DN,然后根据DN和密码,在OpenLDAP上进行验证。
Simple bind authentication splices the login account and the configuration information of Graph services into a DN that can be recognized by OpenLDAP, and then authenticates on OpenLDAP based on the DN and password.

### 搜索绑定认证(SearchBindAuth
### SearchBindAuth

搜索绑定认证会读取Graph服务配置信息,查询配置信息中的`uid`和登录账号是否匹配,如果匹配,就读取这个DN,然后用DN和密码,在OpenLDAP上进行验证。
Search bind authentication reads the Graph service configuration information and queries whether the `uid` in the configuration matches the login account. If they match, search bind authentication reads the DN, and then uses the DN and password to verify on OpenLDAP.

## 前提条件
## Prerequisites

- 已安装[OpenLDAP](https://www.openldap.org/)
- [OpenLDAP](https://www.openldap.org/) is installed.

- 已在OpenLDAP上导入用户的账号和密码信息。
- The account and password are imported on OpenLDAP.

- OpenLDAP所在服务器已开放相应认证端口。
- The server where OpenLDAP is located has opened the corresponding authentication port.

## 操作步骤
## Procedures

以OpenLDAP上已存在的账号`test2`、密码`passwdtest2`为例进行演示。
Take the existing account `test2` and password `passwdtest2` on OpenLDAP as an example.

1. [连接Nebula Graph](../../4.deployment-and-installation/connect-to-nebula-graph.md),创建与OpenLDAP中对应的影子账号`test2`并授权。
1. [Connect to Nebula Graph](../../4.deployment-and-installation/connect-to-nebula-graph.md), create and authorize the shadow account `test2` corresponding to OpenLDAP.

```ngql
nebula> CREATE USER test2 WITH PASSWORD '';
Expand All @@ -42,53 +41,53 @@ OpenLDAP支持的认证方式有两种:简单绑定认证和搜索绑定认证

!!! note

Nebula Graph内创建用户时,密码可以任意设置。
When creating an account in Nebula Graph, the password can be set arbitrarily.

2. 编辑配置文件`nebula-graphd.conf`(默认目录为`/usr/local/nebula/etc/`):
2. Edit the configuration file `nebula-graphd.conf` (The default path is`/usr/local/nebula/etc/`):

- 简单绑定认证(推荐)
- SimpleBindAuth (Recommended)

```bash
# 是否从配置文件获取配置信息。
# Whether to get the configuration information from the configuration file.
--local_config=true
# 是否开启身份验证
# Whether to enable authentication.
--enable_authorize=true
# 身份验证方式:passwordldapcloud
# Authentication methods include password, ldap, and cloud.
--auth_type=ldap
# OpenLDAP服务器地址
# The address of the OpenLDAP server.
--ldap_server=192.168.8.211
# OpenLDAP服务器端口
# The port of the OpenLDAP server.
--ldap_port=389
# OpenLDAP中的Schema名称
# The name of the Schema in OpenLDAP.
--ldap_scheme=ldap
# DN前缀
# The prefix of DN.
--ldap_prefix=uid=
# DN后缀
# The suffix of DN.
--ldap_suffix=,ou=it,dc=sys,dc=com
```

- 搜索绑定认证
- SearchBindAuth

```bash
# 是否从配置文件获取配置信息。
# Whether to get the configuration information from the configuration file.
--local_config=true
# 是否开启身份验证
# Whether to enable authentication.
--enable_authorize=true
# 身份验证方式:passwordldapcloud
# Authentication methods include password, ldap, and cloud.
--auth_type=ldap
# OpenLDAP服务器地址
# The address of the OpenLDAP server.
--ldap_server=192.168.8.211
# OpenLDAP服务器端口
# The port of the OpenLDAP server.
--ldap_port=389
# OpenLDAP中的Schema名称
# The name of the Schema in OpenLDAP.
--ldap_scheme=ldap
# 绑定目标对象的DN
# The DN that binds the target.
--ldap_basedn=uid=test2,ou=it,dc=sys,dc=com
```

3. [重启Nebula Graph服务](../../4.deployment-and-installation/manage-service.md),让新配置生效。
3. [Restart Nebula Graph services](../../4.deployment-and-installation/manage-service.md) to make the new configuration valid.

4. 进行登录测试。
4. Run the login test.

```bash
$ ./nebula-console --addr 127.0.0.1 --port 9669 -u test2 -p passwdtest2
Expand All @@ -99,5 +98,4 @@ OpenLDAP支持的认证方式有两种:简单绑定认证和搜索绑定认证

!!! note

使用OpenLDAP进行身份验证后,本地用户(包括`root`)无法正常登录。
-->
After using OpenLDAP for authentication, local users (including `root`) cannot log in normally.
27 changes: 14 additions & 13 deletions docs-2.0/8.service-tuning/improve-query-by-tag-index.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<!-->
# 增加和删除标签
# Add and delete tags

在openCypher中,有增加标签(`SET label`)和移除标签(`REMOVE label`)的功能,可以用于加速查询或者标记过程。
OpenCypher has the features of `SET label` and `REMOVE label` to speed up the process of querying or labeling.

在Nebula Graph中,可以通过Tag变相实现相同操作,创建Tag并将Tag插入到已有的点上,就可以根据Tag名称快速查找点,也可以通过`DELETE TAG`删除某些点上不再需要的Tag。
Nebula Graph achieves the same operations by creating and inserting tags to an existing vertex, which can quickly query vertices based on the tag name. Users can also run `DELETE TAG` to delete some vertices that are no longer needed.

!!! caution

请确保点上已经有另一个Tag,否则删除点上最后一个Tag时,会导致点也被删除。
Make sure that there is another tag on the vertex. Otherwise, the vertex will be deleted when the last tag is deleted.

## 示例
## Examples

例如在basketballplayer数据集中,部分篮球运动员同时也是球队股东,可以为股东Tag`shareholder`创建索引,方便快速查找。如果不再是股东,可以通过`DELETE TAG`语句删除相应运动员的股东Tag。
For example, in the `basketballplayer` data set, some basketball players are also team shareholders. Users can create an index for the shareholder tag `shareholder` for quick search. If the player is no longer a shareholder, users can delete the shareholder tag of the corresponding player by `DELETE TAG`.

```ngql
//创建股东Tag和索引
//This example creates the shareholder tag and index.
nebula> CREATE TAG shareholder();
nebula> CREATE TAG INDEX shareholder_tag on shareholder();
//为点添加Tag

//This example adds a tag on the vertex.
nebula> INSERT VERTEX shareholder() VALUES "player100":();
nebula> INSERT VERTEX shareholder() VALUES "player101":();
//快速查询所有股东

//This example queries all the shareholders.
nebula> MATCH (v:shareholder) RETURN v;
+---------------------------------------------------------------------+
| v |
Expand All @@ -37,7 +38,8 @@ nebula> LOOKUP ON shareholder;
+-------------+
| "player101" |
+-------------+
//如果player100不再是股东

//In this example, the "player100" is no longer a shareholder.
nebula> DELETE TAG shareholder FROM "player100";
nebula> LOOKUP ON shareholder;
+-------------+
Expand All @@ -49,5 +51,4 @@ nebula> LOOKUP ON shareholder;

!!! note

如果插入测试数据后才创建索引,请用`REBUILD TAG INDEX <index_name_list>;`语句重建索引。
-->
If the index is created after inserting the test data, use the `REBUILD TAG INDEX <index_name_list>;` statement to rebuild the index.