From 31379e973d6d53090c71734410c0737e7f526cb0 Mon Sep 17 00:00:00 2001 From: okiedork Date: Sat, 28 May 2022 10:51:49 -0300 Subject: [PATCH] Add 'username' auth option to Redis driver --- src/Stash/Driver/Redis.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Stash/Driver/Redis.php b/src/Stash/Driver/Redis.php index 1775dd58..dd82bf52 100644 --- a/src/Stash/Driver/Redis.php +++ b/src/Stash/Driver/Redis.php @@ -57,7 +57,10 @@ class Redis extends AbstractDriver * * The "database" option lets developers specific which specific database to use. * - * The "password" option is used for clusters which required authentication. + * The "password" option is used for clusters which require authentication. + * + * The "username" option is used for authentication with a non-default user, for clusters which have ACL rules. + * If "username" isn't set, but "password" is set, the `default` user will be used for authentication. * * @param array $options */ @@ -121,9 +124,18 @@ protected function setOptions(array $options = array()) $redis->connect($server['server'], $port, $ttl); } - // auth - just password + // authentication if (isset($options['password'])) { - $redis->auth($options['password']); + if (isset($options['username'])) { + $redis->auth( + [ + 'user' => $options['username'], + 'pass' => $options['password'] + ] + ); + } else { + $redis->auth(['pass' => $options['password']]); + } } $this->redis = $redis;