]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow redis cluster to use password 15685/head
authorMorris Jobke <hey@morrisjobke.de>
Wed, 22 May 2019 10:19:07 +0000 (12:19 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 22 May 2019 10:19:07 +0000 (12:19 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
config/config.sample.php
lib/private/RedisFactory.php

index b25a4baeadd5df49a6aad45e9518a3ef82e830b9..d7f9b2170617efcf941e0f0d9fe75d8622fbf936 100644 (file)
@@ -1160,15 +1160,19 @@ $CONFIG = array(
  * which then causes a FileLocked exception.
  *
  * See https://redis.io/topics/cluster-spec for details about the Redis cluster
+ *
+ * Authentication works with phpredis version 4.2.1+. See
+ * https://github.com/phpredis/phpredis/commit/c5994f2a42b8a348af92d3acb4edff1328ad8ce1
  */
 'redis.cluster' => [
        'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
                'localhost:7000',
-               'localhost:7001'
+               'localhost:7001',
        ],
        'timeout' => 0.0,
        'read_timeout' => 0.0,
-       'failover_mode' => \RedisCluster::FAILOVER_ERROR
+       'failover_mode' => \RedisCluster::FAILOVER_ERROR,
+       'password' => '', // Optional, if not defined no password will be used.
 ],
 
 
index 22d02e07c2981589f9a65befdbf94772d565f2f4..2224eaca79c1322cc1f55c3322e1d599b3e95683 100644 (file)
@@ -56,7 +56,11 @@ class RedisFactory {
                        } else {
                                $readTimeout = null;
                        }
-                       $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout);
+                       if (isset($config['password']) && $config['password'] !== '') {
+                               $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, false, $config['password']);
+                       } else {
+                               $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout);
+                       }
 
                        if (isset($config['failover_mode'])) {
                                $this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']);