Spring boot version: 2.2.6.RELEASE I get the RedisCommandExecutionException: NOAUTH Authentication required. After setting the configuration like this:
spring:
cache:
cache-names: mycache
type: redis
redis:
password: mypassword
sentinel:
master: mymaster
password: mypassword
nodes: myredis01:26379,myredis02:26379,myredis03:2637{code}
I tried setting only spring.redis.password
, only spring.redis.sentinel.password
and both at the same time and it's not working.
Digging through the code I found that the sentinel password is never set on the configuration:
1- org.springframework.boot.autoconfigure.data.redis.RedisProperties.Sentinel
doesn't have the 'password' property.
2- org.springframework.boot.autoconfigure.data.redis.RedisConnectionConfiguration#getSentinelConfig()
never sets the existing property 'sentinelPassword' in RedisSentinelConfiguration
.
3 - Resulting in the org.springframework.data.redis.connection.lettuce.LettuceConverters
setting always a null password which is the default when not set in the sentinelConfigurationToRedisURI
method.
So the problem comes when the sentinel is also password protected. I mistakenly filed the bug on the Spring redis data and they sent me here.
regards,
Comment From: mbhave
This is the Spring Data issue for reference.
Based on some comments from #18942, we didn't surface a property for spring.redis.sentinel.password
because Sentinel authentication was only supported by Lettuce and not by Jedis.
@mp911de What are your thoughts on surfacing a property that applies to one driver and not the other?
Comment From: mcanessa
Hello, i found this Jedis merge.
Comment From: mp911de
Back then, Jedis didn't provide an option to configure the Sentinel password. In the meantime, Jedis provided the required functionality so I filed DATAREDIS-1145 to support Sentinel passwords with Jedis in Spring Data Redis.
That being said, it makes sense to surface the password property in the spring.redis.sentinel
namespace.
Comment From: philwebb
We'll add a spring.redis.sentinel.password
property. A value of null
will mean use the spring.redis.password
property. An empty string or value will be configured on the sentinel.
Comment From: mp911de
We've tried a similar approach in Spring Data Redis and learned that we should not couple the Redis password to the Sentinel password. The Sentinel password was added in a later Redis version so earlier Redis setups will fail when the Sentinel password is set to the Redis password.
Comment From: philwebb
@mp911de Interesting. We currently have code that sets the sentinel password to the redis one and we were worried about back compatibility. After discussing it some more, we'll just add a new property and make the user set it if they want to use the same value.
Comment From: mbhave
Looking at the code further, I don't think there's a back compatibility issue as we've never set the sentinelPassword
. Even in the RedisSentinelConfiguration
, it was the dataNodePassword
that we configured.