DATAREDIS-524 - Use password to connect Redis nodes using Sentinel.

LettuceConnectionFactory and DefaultLettucePool now use the configured password to authenticate with Redis. Authentication is applied when connecting to nodes that were obtained from Redis Sentinel.

Original Pull Request: #204
This commit is contained in:
Mark Paluch
2016-06-22 09:35:07 +02:00
committed by Christoph Strobl
parent 74a5652ff0
commit ea33cd40e6
4 changed files with 61 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.redis.connection.PoolException;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import com.lambdaworks.redis.RedisAsyncConnection;
import com.lambdaworks.redis.RedisClient;
@@ -120,7 +121,13 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
private RedisURI getRedisURI() {
if (isRedisSentinelAware()) {
return LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
RedisURI redisURI = LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
if (StringUtils.hasText(password)) {
redisURI.setPassword(password);
}
return redisURI;
}
return createSimpleHostRedisURI();

View File

@@ -607,7 +607,14 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
}
private RedisURI getSentinelRedisURI() {
return LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
RedisURI redisURI = LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
if (StringUtils.hasText(password)) {
redisURI.setPassword(password);
}
return redisURI;
}
/**