Skip to content

Commit 9477bcf

Browse files
authored
docs: MUST_CHANGE_PASSWORD (#964)
* updates * added example
1 parent 41f256c commit 9477bcf

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

docs/en/sql-reference/10-sql-commands/00-ddl/02-user/01-user-create-user.md

+36-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 1
44
---
55
import FunctionDescription from '@site/src/components/FunctionDescription';
66

7-
<FunctionDescription description="Introduced or updated: v1.2.424"/>
7+
<FunctionDescription description="Introduced or updated: v1.2.566"/>
88

99
Creates a SQL user.
1010

@@ -18,13 +18,15 @@ See also:
1818

1919
```sql
2020
CREATE [ OR REPLACE ] USER <name> IDENTIFIED [ WITH <auth_type> ] BY '<password>'
21+
[ WITH MUST_CHANGE_PASSWORD = true | false ]
2122
[ WITH SET PASSWORD POLICY = '<policy_name>' ] -- Set password policy
2223
[ WITH SET NETWORK POLICY = '<policy_name>' ] -- Set network policy
2324
[ WITH DEFAULT_ROLE = '<role_name>' ] -- Set default role
2425
[ WITH DISABLED = true | false ] -- User created in a disabled state
2526
```
2627

2728
- *auth_type* can be `double_sha1_password` (default), `sha256_password` or `no_password`.
29+
- When `MUST_CHANGE_PASSWORD` is set to `true`, the new user must change password at first login. Users can change their own password using the [ALTER USER](03-user-alter-user.md) command.
2830
- When you set a default role for a user using CREATE USER or [ALTER USER](03-user-alter-user.md), Databend does not verify the role's existence or automatically grant the role to the user. You must explicitly grant the role to the user for the role to take effect.
2931
- When `DISABLED` is set to `true`, the new user is created in a disabled state. Users in this state cannot log in to Databend until they are enabled. To enable or disable a created user, use the [ALTER USER](03-user-alter-user.md) command.
3032

@@ -153,4 +155,37 @@ ALTER USER u1 WITH DISABLED = FALSE;
153155
Welcome to BendSQL 0.16.0-homebrew.
154156
Connecting to localhost:8000 as user u1.
155157
Connected to Databend Query v1.2.424-nightly-d3a89f708d(rust-1.77.0-nightly-2024-04-17T22:11:59.304509266Z)
158+
```
159+
160+
### Example 6: Creating User with MUST_CHANGE_PASSWORD
161+
162+
In this example, we will create a user with the `MUST_CHANGE_PASSWORD` option. Then, we will connect to Databend with BendSQL as the new user and change the password.
163+
164+
1. Create a new user named 'eric' with the `MUST_CHANGE_PASSWORD` option set to `TRUE`.
165+
166+
```sql
167+
CREATE USER eric IDENTIFIED BY 'abc123' WITH MUST_CHANGE_PASSWORD = TRUE;
168+
```
169+
170+
2. Launch BendSQL and connect to Databend as the new user. Once connected, you'll see a message indicating that a password change is required.
171+
172+
```bash
173+
MacBook-Air:~ eric$ bendsql -ueric -pabc123
174+
```
175+
176+
3. Change the password with the [ALTER USER](03-user-alter-user.md) command.
177+
178+
```bash
179+
eric@localhost:8000/default> ALTER USER USER() IDENTIFIED BY 'abc456';
180+
```
181+
182+
4. Quit BendSQL then reconnect with the new password.
183+
184+
```bash
185+
MacBook-Air:~ eric$ bendsql -ueric -pabc456
186+
Welcome to BendSQL 0.19.2-1e338e1(2024-07-17T09:02:28.323121000Z).
187+
Connecting to localhost:8000 as user eric.
188+
Connected to Databend Query v1.2.567-nightly-78d41aedc7(rust-1.78.0-nightly-2024-07-14T22:10:13.777450105Z)
189+
190+
eric@localhost:8000/default>
156191
```

docs/en/sql-reference/10-sql-commands/00-ddl/02-user/03-user-alter-user.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 2
44
---
55
import FunctionDescription from '@site/src/components/FunctionDescription';
66

7-
<FunctionDescription description="Introduced or updated: v1.2.424"/>
7+
<FunctionDescription description="Introduced or updated: v1.2.566"/>
88

99
Modifies a user account, including:
1010

@@ -17,7 +17,13 @@ Modifies a user account, including:
1717

1818
```sql
1919
-- Modify password / authentication type
20-
ALTER USER <name> IDENTIFIED [ WITH auth_type ] BY '<password>'
20+
ALTER USER <name> IDENTIFIED [ WITH auth_type ] BY '<new_password>' [ WITH MUST_CHANGE_PASSWORD = true | false ]
21+
22+
-- Require user to modify password at next login
23+
ALTER USER <name> WITH MUST_CHANGE_PASSWORD = true
24+
25+
-- Modify password for currently logged-in user
26+
ALTER USER USER() IDENTIFIED BY '<new_password>'
2127

2228
-- Set password policy
2329
ALTER USER <name> WITH SET PASSWORD POLICY = '<policy_name>'
@@ -39,6 +45,7 @@ ALTER USER <name> WITH DISABLED = true | false
3945
```
4046

4147
- *auth_type* can be `double_sha1_password` (default), `sha256_password` or `no_password`.
48+
- When `MUST_CHANGE_PASSWORD` is set to `true`, the user must change their password at the next login. Please note that this takes effect only for users who have never changed their password since their account was created. If a user has ever changed their password themselves, then they do not need to change it again.
4249
- When you set a default role for a user using [CREATE USER](01-user-create-user.md) or ALTER USER, Databend does not verify the role's existence or automatically grant the role to the user. You must explicitly grant the role to the user for the role to take effect.
4350
- `DISABLED` allows you to enable or disable a user. Disabled users cannot log in to Databend until they are enabled. Click [here](01-user-create-user.md#example-5-creating-user-in-disabled-state) to see an example.
4451

0 commit comments

Comments
 (0)