From 5f61e3595694b53bfa763464e6a7be655235ed74 Mon Sep 17 00:00:00 2001 From: Gennadii Chernykh Date: Mon, 2 Dec 2024 12:36:56 +0400 Subject: [PATCH 1/4] Redis ACL AUTH two argument supporting. Signed-off-by: Gennadii Chernykh Signed-off-by: Gennadii Chernykh --- src/Prometheus/Storage/Redis.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 122d11a3..cb1d5670 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -28,6 +28,7 @@ class Redis implements Adapter 'read_timeout' => '10', 'persistent_connections' => false, 'password' => null, + 'user' => null, ]; /** @@ -196,8 +197,18 @@ private function ensureOpenConnection(): void $this->connectToServer(); - if ($this->options['password'] !== null) { - $this->redis->auth($this->options['password']); + $authParams = []; + + 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'])) { From 7af3c867193d27e7a426900b9f176cdcc1200c4c Mon Sep 17 00:00:00 2001 From: Gennadii Chernykh Date: Mon, 2 Dec 2024 12:55:10 +0400 Subject: [PATCH 2/4] Redis ACL AUTH two argument supporting. Signed-off-by: Gennadii Chernykh Signed-off-by: Gennadii Chernykh --- src/Prometheus/Storage/Redis.php | 1 - src/Prometheus/Storage/RedisNg.php | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index cb1d5670..58de5b7d 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -196,7 +196,6 @@ private function ensureOpenConnection(): void } $this->connectToServer(); - $authParams = []; if (isset($this->options['user'])) { diff --git a/src/Prometheus/Storage/RedisNg.php b/src/Prometheus/Storage/RedisNg.php index cb369ba7..7340db18 100644 --- a/src/Prometheus/Storage/RedisNg.php +++ b/src/Prometheus/Storage/RedisNg.php @@ -28,6 +28,7 @@ class RedisNg implements Adapter 'read_timeout' => '10', 'persistent_connections' => false, 'password' => null, + 'user' => null, ]; /** @@ -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'])) { From 66cdb3024369f4cf5e3819be3a25bbe1f645517f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Mon, 2 Dec 2024 13:17:04 +0100 Subject: [PATCH 3/4] Fix not using empty in Redis Adapter --- src/Prometheus/Storage/Redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 6ba6f800..0a4096eb 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -206,7 +206,7 @@ private function ensureOpenConnection(): void $authParams[] = $this->options['password']; } - if (!empty($authParams)) { + if ($authParams !== []) { $this->redis->auth($authParams); } From 27e01b52cc2ec1e75de8193a36887e32478be025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Mon, 2 Dec 2024 13:17:41 +0100 Subject: [PATCH 4/4] Fix not using empty in RedisNg Adapter --- src/Prometheus/Storage/RedisNg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Prometheus/Storage/RedisNg.php b/src/Prometheus/Storage/RedisNg.php index 7340db18..865a07ed 100644 --- a/src/Prometheus/Storage/RedisNg.php +++ b/src/Prometheus/Storage/RedisNg.php @@ -206,7 +206,7 @@ private function ensureOpenConnection(): void $authParams[] = $this->options['password']; } - if (!empty($authParams)) { + if ($authParams !== []) { $this->redis->auth($authParams); }