Skip to content

Commit

Permalink
[9.x] Add username option for phpredis with redis ACL (#41683)
Browse files Browse the repository at this point in the history
* Update PhpRedisConnector.php

Allow to use username and password string for phpredis connection, instead of a password array.
Fix laravel crash if different environement (ex: one server with ACL, one with just a password), have to edit database.php to use an array in password field. Now you can use username and password.

* Update PhpRedisConnector.php

* formatting

* remove whitespace

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
neoteknic and taylorotwell committed Mar 25, 2022
1 parent d89400b commit 92f9006
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Illuminate/Redis/Connectors/PhpRedisConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ protected function createClient(array $config)
$this->establishConnection($client, $config);

if (! empty($config['password'])) {
$client->auth($config['password']);
if (isset($config['username']) && is_string($config['password'])) {
$client->auth([$config['username'], $config['password']]);
} else {
$client->auth($config['password']);
}
}

if (isset($config['database'])) {
Expand Down

0 comments on commit 92f9006

Please sign in to comment.