diff --git a/CHANGELOG b/CHANGELOG index 86e8a54dc0..2fa5c87b5d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ Version 1.1.30 under development - Bug #4544: PHP 8 compatibility: Fix deprecation in CLocale (apphp) - Bug #4566: PHP 8 compatibility: Fix passing null to string parameter parameter (apphp) - Enh #4552: Added support for PHP 8.3 (sandippingle, ThePepster, marcovtwout) +- Enh #4559: Added support for Redis ACL authentication with username for Redis 6+ (arfeen) - Enh #4568: Add missing hungarian translations (albertborsos) Version 1.1.29 November 14, 2023 diff --git a/framework/caching/CRedisCache.php b/framework/caching/CRedisCache.php index 15d4488ac6..4df691c708 100644 --- a/framework/caching/CRedisCache.php +++ b/framework/caching/CRedisCache.php @@ -31,6 +31,7 @@ * 'port'=>6379, * 'database'=>0, * 'options'=>STREAM_CLIENT_CONNECT, + * 'username' => 'default' // only for REDIS version 6.0 or later * ), * ), * ) @@ -52,6 +53,10 @@ class CRedisCache extends CCache * @var int the port to use for connecting to the redis server. Default port is 6379. */ public $port=6379; + /** + * @var string the username to use to authenticate with the redis server. If set, AUTH command will be sent with username. + */ + public $username; /** * @var string the password to use to authenticate with the redis server. If not set, no AUTH command will be sent. */ @@ -96,8 +101,14 @@ protected function connect() { if($this->ssl) stream_socket_enable_crypto($this->_socket,true,STREAM_CRYPTO_METHOD_TLS_CLIENT); - if($this->password!==null) - $this->executeCommand('AUTH',array($this->password)); + if ($this->password !== null) { + if ($this->username !== null) { + $this->executeCommand('AUTH',array($this->username, $this->password)); + } else { + $this->executeCommand('AUTH',array($this->password)); + } + } + $this->executeCommand('SELECT',array($this->database)); } else