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

update ip whitelist #1561

Merged
merged 2 commits into from
Mar 16, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ SHOW USERS;

```ngql
nebula> SHOW USERS;
+---------+
| Account |
+---------+
| "root" |
| "user1" |
+---------+
+---------+-----------------+
| Account | IP Whitelist |
+---------+-----------------+
| "root" | "" |
| "user1" | "" |
| "user2" | "192.168.10.10" |
+---------+-----------------+
```
52 changes: 40 additions & 12 deletions docs-2.0/7.data-security/1.authentication/2.management-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@
- 语法

```ngql
CREATE USER [IF NOT EXISTS] <user_name> [WITH PASSWORD '<password>'];
CREATE USER [IF NOT EXISTS] <user_name> [WITH PASSWORD '<password>'] [WITH IP WHITELIST <ip_list>];
```

- `IF NOT EXISTS`:检测待创建的用户名是否存在,只有不存在时,才会创建新用户。
- `user_name`:待创建的用户名。
- `password`:用户名对应的密码。
- `ip_list`(企业版):IP 白名单列表。该用户只有通过列表内的 IP 才能连接 Nebula Graph。多个 IP 之间用英文逗号(,)分隔。

- 示例

```ngql
nebula> CREATE USER user1 WITH PASSWORD 'nebula';
nebula> CREATE USER user2 WITH PASSWORD 'nebula' WITH IP WHITELIST 192.168.10.10,192.168.10.12;
nebula> SHOW USERS;
+---------+-------------------------------+
| Account | IP Whitelist |
+---------+-------------------------------+
| "root" | "" |
| "user1" | "" |
| "user2" | "192.168.10.10,192.168.10.12" |
+---------+-------------------------------+
```

## 授权用户(`GRANT ROLE`)
Expand Down Expand Up @@ -116,20 +130,34 @@
nebula> CHANGE PASSWORD user1 FROM 'nebula' TO 'nebula123';
```

## 修改用户密码(`ALTER USER`)
## 修改用户密码和 IP 白名单(`ALTER USER`)

执行`ALTER USER`语句可以修改用户密码,修改时不需要提供旧密码。当前仅** God **角色用户(即`root`用户)能够执行`ALTER USER`语句。
执行`ALTER USER`语句可以修改用户密码和 IP 白名单,修改时不需要提供旧密码。当前仅** God **角色用户(即`root`用户)能够执行`ALTER USER`语句。

- 语法

```ngql
ALTER USER <user_name> WITH PASSWORD '<password>';
ALTER USER <user_name> WITH PASSWORD '<password>' [WITH IP WHITELIST <ip_list>];
```

- 示例

!!! enterpriseonly

没有使用`WITH IP WHITELIST`时,表示取消 IP 白名单,用户使用任何 IP 都可以连接 Nebula Graph。

```ngql
nebula> ALTER USER user1 WITH PASSWORD 'nebula';
nebula> ALTER USER user2 WITH PASSWORD 'nebula';
nebula> SHOW USERS;
+---------+--------------+
| Account | IP Whitelist |
+---------+--------------+
| "root" | "" |
| "user1" | "" |
| "user2" | "" |
+---------+--------------+

nebula> ALTER USER user2 WITH PASSWORD 'nebula' WITH IP WHITELIST 192.168.10.10;
```

## 删除用户(`DROP USER`)
Expand Down Expand Up @@ -166,11 +194,11 @@

```ngql
nebula> SHOW USERS;
+-----------+
| Account |
+-----------+
| "test1" |
| "test2" |
| "test3" |
+-----------+
+---------+-----------------+
| Account | IP Whitelist |
+---------+-----------------+
| "root" | "" |
| "user1" | "" |
| "user2" | "192.168.10.10" |
+---------+-----------------+
```