From 933c6ab4f9c926932a5a77d7f6b78434689a17f7 Mon Sep 17 00:00:00 2001 From: Oleg Posyniak Date: Thu, 11 Aug 2022 14:56:10 -0500 Subject: [PATCH] Add username to auth params --- Cm/Cache/Backend/Redis.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Cm/Cache/Backend/Redis.php b/Cm/Cache/Backend/Redis.php index 1505f94..5e39b70 100644 --- a/Cm/Cache/Backend/Redis.php +++ b/Cm/Cache/Backend/Redis.php @@ -147,6 +147,7 @@ protected function getClientOptions($options = array()) $clientOptions->connectRetries = isset($options['connect_retries']) ? (int) $options['connect_retries'] : self::DEFAULT_CONNECT_RETRIES; $clientOptions->readTimeout = isset($options['read_timeout']) ? (float) $options['read_timeout'] : NULL; $clientOptions->password = isset($options['password']) ? $options['password'] : NULL; + $clientOptions->username = isset($options['username']) ? $options['username'] : NULL; $clientOptions->database = isset($options['database']) ? (int) $options['database'] : 0; $clientOptions->persistent = isset($options['persistent']) ? $options['persistent'] : ''; $clientOptions->timeout = isset($options['timeout']) ? $options['timeout'] : self::DEFAULT_CONNECT_TIMEOUT; @@ -420,7 +421,11 @@ protected function _applyClientOptions(Credis_Client $client, $forceSelect = FAL } if ($clientOptions->password) { - $client->auth($clientOptions->password) or Zend_Cache::throwException('Unable to authenticate with the redis server.'); + if ($clientOptions->username) { + $client->auth($clientOptions->password, $clientOptions->username) or Zend_Cache::throwException('Unable to authenticate with the redis server.'); + } else { + $client->auth($clientOptions->password) or Zend_Cache::throwException('Unable to authenticate with the redis server.'); + } } // Always select database when persistent is used in case connection is re-used by other clients