Skip to content

Commit

Permalink
Merge pull request #169 from shiftedreality/fix-auth
Browse files Browse the repository at this point in the history
Add username to auth params
  • Loading branch information
colinmollenhour authored Aug 12, 2022
2 parents f5d8553 + 933c6ab commit 6661e3f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Cm/Cache/Backend/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6661e3f

Please sign in to comment.