Skip to content

Commit

Permalink
Redis ACL AUTH two argument supporting. (#167)
Browse files Browse the repository at this point in the history
* Redis ACL AUTH two argument supporting.
Signed-off-by: Gennadii Chernykh <ragnarek45@gmail.com>

Signed-off-by: Gennadii Chernykh <gennadii.chernykh@eglobal-group.com>

* Redis ACL AUTH two argument supporting.
Signed-off-by: Gennadii Chernykh <ragnarek45@gmail.com>

Signed-off-by: Gennadii Chernykh <gennadii.chernykh@eglobal-group.com>

* Fix not using empty in Redis Adapter

* Fix not using empty in RedisNg Adapter

---------

Signed-off-by: Gennadii Chernykh <gennadii.chernykh@eglobal-group.com>
Co-authored-by: Gennadii Chernykh <gennadii.chernykh@eglobal-group.com>
Co-authored-by: Lukas Kämmerling <github@lukas-kaemmerling.de>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent d6233cc commit abe6bbb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Redis 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 ($authParams !== []) {
$this->redis->auth($authParams);
}

if (isset($this->options['database'])) {
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 ($authParams !== []) {
$this->redis->auth($authParams);
}

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

0 comments on commit abe6bbb

Please sign in to comment.