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:
committed by
Christoph Strobl
parent
74a5652ff0
commit
ea33cd40e6
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user