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 <[email protected]>

Signed-off-by: Gennadii Chernykh <[email protected]>
  • Loading branch information
Gennadii Chernykh committed Dec 2, 2024
1 parent 5f61e35 commit 7af3c86
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)) {

Check failure on line 209 in src/Prometheus/Storage/RedisNg.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.1

Construct empty() is not allowed. Use more strict comparison.

Check failure on line 209 in src/Prometheus/Storage/RedisNg.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.2

Construct empty() is not allowed. Use more strict comparison.

Check failure on line 209 in src/Prometheus/Storage/RedisNg.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP 8.3

Construct empty() is not allowed. Use more strict comparison.
$this->redis->auth($authParams);
}

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

0 comments on commit 7af3c86

Please sign in to comment.