Skip to content

Commit abe6bbb

Browse files
RagagaGennadii ChernykhLKaemmerling
authored
Redis ACL AUTH two argument supporting. (#167)
* 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>
1 parent d6233cc commit abe6bbb

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/Prometheus/Storage/Redis.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Redis implements Adapter
2828
'read_timeout' => '10',
2929
'persistent_connections' => false,
3030
'password' => null,
31+
'user' => null,
3132
];
3233

3334
/**
@@ -195,9 +196,18 @@ private function ensureOpenConnection(): void
195196
}
196197

197198
$this->connectToServer();
199+
$authParams = [];
198200

199-
if ($this->options['password'] !== null) {
200-
$this->redis->auth($this->options['password']);
201+
if (isset($this->options['user'])) {
202+
$authParams[] = $this->options['user'];
203+
}
204+
205+
if (isset($this->options['password'])) {
206+
$authParams[] = $this->options['password'];
207+
}
208+
209+
if ($authParams !== []) {
210+
$this->redis->auth($authParams);
201211
}
202212

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

src/Prometheus/Storage/RedisNg.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class RedisNg implements Adapter
2828
'read_timeout' => '10',
2929
'persistent_connections' => false,
3030
'password' => null,
31+
'user' => null,
3132
];
3233

3334
/**
@@ -195,9 +196,18 @@ private function ensureOpenConnection(): void
195196
}
196197

197198
$this->connectToServer();
199+
$authParams = [];
198200

199-
if ($this->options['password'] !== null) {
200-
$this->redis->auth($this->options['password']);
201+
if (isset($this->options['user'])) {
202+
$authParams[] = $this->options['user'];
203+
}
204+
205+
if (isset($this->options['password'])) {
206+
$authParams[] = $this->options['password'];
207+
}
208+
209+
if ($authParams !== []) {
210+
$this->redis->auth($authParams);
201211
}
202212

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

0 commit comments

Comments
 (0)