Skip to content

Commit b0f2550

Browse files
authored
Merge pull request #462 from codecrafters-io/TropicolX-patch-87
Revise "The AUTH command #hz3"
2 parents 8c77e06 + 24a4cae commit b0f2550

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

stage_descriptions/auth-06-hz3.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
In this stage, you'll add support for responding to the `AUTH` command.
1+
In this stage, you'll add support for the `AUTH` command.
22

3-
### The `AUTH` command
3+
### The `AUTH` Command
44

5-
The [`AUTH`](https://redis.io/docs/latest/commands/auth/) command is used to authenticate the current connection with the specified user.
5+
The [`AUTH`](https://redis.io/docs/latest/commands/auth/) command authenticates the current connection with a specified username and password.
66

7-
Example usage:
7+
The command format is:
8+
9+
```bash
10+
AUTH <username> <password>
11+
```
12+
13+
For example:
814

915
```bash
1016
# Authentication failure
@@ -16,11 +22,11 @@ Example usage:
1622
OK
1723
```
1824

19-
The `AUTH` command responds with `+OK\r\n` if the specified password's hash matches with any of the hashes in the user's password list.
25+
The server responds with `+OK\r\n` if the specified password's hash matches any of the hashes in the user's password list.
2026

21-
In case of wrong password, the response is a RESP simple error `WRONGPASS invalid username-password pair or user is disabled.`.
27+
If no match is found, the server responds with the [RESP simple error](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-errors): `WRONGPASS invalid username-password pair or user is disabled.`
2228

23-
In this stage, you just need to respond to the `AUTH` command appropriately. You don't actually need to authenticate the connection. We'll get to that in the later stages.
29+
For this stage, you just need to respond to the `AUTH` command appropriately. You don't need to actually authenticate the connection. We'll get to that in later stages.
2430

2531
### Tests
2632

@@ -30,18 +36,16 @@ The tester will execute your program like this:
3036
$ ./your_program.sh
3137
```
3238

33-
It'll then send a `ACL SETUSER` command, specifying the `default` user and a password.
39+
It will then send an `ACL SETUSER` command, specifying the `default` user and a password:
3440

3541
```bash
36-
$ redis-cli
37-
# Expect: +OK\r\n
38-
> ACL SETUSER default >mypassword
42+
$ redis-cli ACL SETUSER default >mypassword
3943
OK
4044
```
4145

42-
The tester will validate that the response to the `ACL SETUSER` command is `+OK\r\n`.
46+
Your server should respond with `OK` encoded as a simple string (`+OK\r\n`).
4347

44-
It'll then send two `AUTH` commands, specifying the `default` user. First, it'll send a wrong password. Next, it'll send the correct password.
48+
Next, the tester will send two `AUTH` commands: one with a wrong password and another with a correct password.
4549

4650
```bash
4751
# Expect error starting with: WRONGPASS
@@ -53,13 +57,12 @@ It'll then send two `AUTH` commands, specifying the `default` user. First, it'll
5357
OK
5458
```
5559

56-
The tester will validate the following for the responses to the `AUTH` command:
57-
58-
- In case of incorrect password, the response is a RESP simple error starting with the string `WRONGPASS`.
59-
- In case of correct password, the response is `+OK\r\n`.
60+
The tester will verify that:
61+
- Wrong passwords return a [simple error](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-errors) starting with `WRONGPASS`.
62+
- Correct passwords return `+OK\r\n`.
6063

6164
### Notes
6265

63-
- The tester will be lenient in checking error messages. Any authentication failure starting with `WRONGPASS` is valid. For example,
66+
- The tester will be lenient in checking error messages. Any authentication failure starting with `WRONGPASS` is valid. For example:
6467
- `WRONGPASS wrong password`
65-
- `WRONGPASS invalid authentication`
68+
- `WRONGPASS invalid authentication`

0 commit comments

Comments
 (0)