diff options
author | Pavlo Yatsukhnenko <yatsukhnenko@users.noreply.github.com> | 2019-01-21 12:57:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-21 12:57:35 +0300 |
commit | 3aad9e653bf85072602a1f3b8dcf888891a9206e (patch) | |
tree | fc7935bfeaba7119ca91ca3df0108f9ef2d0faad /redis_session.c | |
parent | e9e47834560fd2e2b118150572eae3379a245cb3 (diff) | |
parent | c5994f2a42b8a348af92d3acb4edff1328ad8ce1 (diff) |
Merge pull request #1494 from phpredis/cluster-auth2
RedisCluster auth
Diffstat (limited to 'redis_session.c')
-rw-r--r-- | redis_session.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/redis_session.c b/redis_session.c index 2f75d5b1..a02c1897 100644 --- a/redis_session.c +++ b/redis_session.c @@ -981,9 +981,9 @@ PS_OPEN_FUNC(rediscluster) { zval z_conf, *z_val; HashTable *ht_conf, *ht_seeds; double timeout = 0, read_timeout = 0; - int persistent = 0; - int retval, prefix_len, failover = REDIS_FAILOVER_NONE; - char *prefix; + int retval, persistent = 0, failover = REDIS_FAILOVER_NONE; + strlen_t prefix_len, auth_len = 0; + char *prefix, *auth = NULL; /* Parse configuration for session handler */ array_init(&z_conf); @@ -1030,7 +1030,7 @@ PS_OPEN_FUNC(rediscluster) { /* Look for a specific failover setting */ if ((z_val = zend_hash_str_find(ht_conf, "failover", sizeof("failover") - 1)) != NULL && - Z_TYPE_P(z_val) == IS_STRING + Z_TYPE_P(z_val) == IS_STRING && Z_STRLEN_P(z_val) > 0 ) { if (!strcasecmp(Z_STRVAL_P(z_val), "error")) { failover = REDIS_FAILOVER_ERROR; @@ -1039,7 +1039,18 @@ PS_OPEN_FUNC(rediscluster) { } } + /* Look for a specific auth setting */ + if ((z_val = zend_hash_str_find(ht_conf, "auth", sizeof("auth") - 1)) != NULL && + Z_TYPE_P(z_val) == IS_STRING && Z_STRLEN_P(z_val) > 0 + ) { + auth = Z_STRVAL_P(z_val); + auth_len = Z_STRLEN_P(z_val); + } + c = cluster_create(timeout, read_timeout, failover, persistent); + if (auth && auth_len > 0) { + c->auth = zend_string_init(auth, auth_len, 0); + } if (!cluster_init_seeds(c, ht_seeds) && !cluster_map_keyspace(c TSRMLS_CC)) { /* Set up our prefix */ c->flags->prefix = zend_string_init(prefix, prefix_len, 0); |