Skip to content

Commit 57fcc37

Browse files
committed
feat: add Redis username authentication support
- Add username config option to Redis configuration - Support both username+password and password-only auth methods - Maintain backward compatibility with existing password-only setups - Improve error messages for authentication failures Signed-off-by: Sanil Shrestha <sanil.shrestha@formbay.com.au>
1 parent 19f8292 commit 57fcc37

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Config/Queue.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Queue extends BaseConfig
5555
*/
5656
public array $redis = [
5757
'host' => '127.0.0.1',
58+
'username' => null,
5859
'password' => null,
5960
'port' => 6379,
6061
'timeout' => 0,

src/Handlers/RedisHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public function __construct(protected QueueConfig $config)
4141
throw new CriticalError('Queue: Redis connection failed. Check your configuration.');
4242
}
4343

44-
if (isset($config->redis['password']) && ! $this->redis->auth($config->redis['password'])) {
45-
throw new CriticalError('Queue: Redis authentication failed.');
44+
if (!empty($config->redis['username']) && !empty($config->redis['password']) && !$this->redis->auth([$config->redis['username'], $config->redis['password']])) {
45+
throw new CriticalError('Queue: Redis authentication failed. Check your username and password.');
46+
} elseif (!empty($config->redis['password']) && !$this->redis->auth($config->redis['password'])) {
47+
throw new CriticalError('Queue: Redis authentication failed. Check your password.');
4648
}
4749

4850
if (isset($config->redis['database']) && ! $this->redis->select($config->redis['database'])) {

0 commit comments

Comments
 (0)