Skip to content

Commit e219502

Browse files
committed
Update README to support username+password authentication for Redis connections (Redis 6+ ACL)
1 parent 745c28a commit e219502

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,17 @@ $redis = new Clue\React\Redis\RedisClient('localhost');
336336
$redis = new Clue\React\Redis\RedisClient('redis://localhost:6379');
337337
```
338338

339-
Redis supports password-based authentication (`AUTH` command). Note that Redis'
340-
authentication mechanism does not employ a username, so you can pass the
341-
password `h@llo` URL-encoded (percent-encoded) as part of the URI like this:
339+
Starting with Redis 6, you can use ACLs and authenticate with both a
340+
username and a password. Any URI containing user:pass@ will now invoke
341+
the AUTH <user> <pass> command under the hood. For example:
342+
343+
```php
344+
// Authenticate with username and password (Redis 6+ ACL)
345+
$redis = new Clue\React\Redis\RedisClient('redis://mauricio:mypass@localhost:6379');
346+
```
347+
348+
If you omit the username (or use an empty userinfo part), the client will fall back
349+
to the legacy AUTH <pass> behavior:
342350

343351
```php
344352
// all forms are equivalent
@@ -489,7 +497,15 @@ that eventually *fulfills* with its *results* on success or *rejects* with an
489497
#### callAsync()
490498

491499
The `callAsync(string $command, string|int|float ...$args): PromiseInterface<mixed>` method can be used to
492-
invoke a Redis command.
500+
invoke a Redis command. Note that the `AUTH` command now supports **two** arguments for Redis 6+ ACL mode:
501+
502+
```php
503+
// authenticate with username + password (Redis 6+)
504+
$redis->callAsync('AUTH', 'alice', 'hunter2');
505+
506+
// legacy password-only mode
507+
$redis->callAsync('AUTH', 'hunter2');
508+
```
493509

494510
For example, the [`GET` command](https://redis.io/commands/get) can be invoked
495511
like this:

0 commit comments

Comments
 (0)