Skip to content

Commit

Permalink
Redis ACL AUTH two argument supporting.
Browse files Browse the repository at this point in the history
Signed-off-by: Gennadii Chernykh <ragnarek45@gmail.com>
  • Loading branch information
Gennadii Chernykh committed Dec 2, 2024
1 parent ec6feb5 commit 2b8f5b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ private function ensureOpenConnection(): void
}

$this->connectToServer();

$authParams = [];

if (isset($this->options['user'])) {
Expand Down
14 changes: 12 additions & 2 deletions src/Prometheus/Storage/RedisNg.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RedisNg implements Adapter
'read_timeout' => '10',
'persistent_connections' => false,
'password' => null,
'user' => null,
];

/**
Expand Down Expand Up @@ -195,9 +196,18 @@ private function ensureOpenConnection(): void
}

$this->connectToServer();
$authParams = [];

if ($this->options['password'] !== null) {
$this->redis->auth($this->options['password']);
if (isset($this->options['user'])) {
$authParams[] = $this->options['user'];
}

if (isset($this->options['password'])) {
$authParams[] = $this->options['password'];
}

if (!empty($authParams)) {
$this->redis->auth($authParams);
}

if (isset($this->options['database'])) {
Expand Down

0 comments on commit 2b8f5b4

Please sign in to comment.