diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 2763565..0a4096e 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, ]; /** @@ -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'])) { diff --git a/src/Prometheus/Storage/RedisNg.php b/src/Prometheus/Storage/RedisNg.php index cb369ba..865a07e 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 ($authParams !== []) { + $this->redis->auth($authParams); } if (isset($this->options['database'])) {