-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Redis Sentinel authentication #1002
Comments
Thanks a lot for the ticket. I wasn't aware of the sentinel change and TBH, I'm not quite sure how to deal with that. |
NOAUTH Authentication required
Thanks for the fast response. |
Thanks for the heads up. I took a look and the |
Redis now supports authentication against Redis Sentinel that was introduced with Redis 5.0.1. The password can be only set programmatically as URI-based user-info applies to the actual Redis server. RedisURI sentinelUrl = RedisURI.Builder.sentinel("host", 26379, "my-master", "some-password").build();
That is now in place. |
@mp911de How is this to be used with Spring Boot? I am running into the same issue where I have a password on both my Sentinel and Redis node (same password), but upgrading to I have this in my gradle file:
When running
My application properties has this:
Yet, when starting up, I still get the same exception: |
Please upgrade to Spring Data Redis 2.2. Earlier Spring Data Redis versions do not set the password on |
Upgraded Spring Data Redis to 2.2.0:
Still same issue. |
I took a look, |
You're saying this is an issue with spring-data-redis? Can open a ticket, yeah. |
This comment has been minimized.
This comment has been minimized.
Regrading the previous off-topic comment, I had to disable the sentinel password on my cluster to get spring-data-redis to connect. I am using the latest Spring Boot 2.2.6. |
@andrew-landsverk-win i've just connected to Redis sentinel from springboot-2.2.6 successful. |
@huyto000 thanks for the reply, do you know of a way to set |
Same problems here, sprng-boot-starter-data-redis:2.2.1:RELEASE UPDATED: Got to set requirepass which is the same as the password in Redis instance's redis.conf in sentinel.conf. |
I recently noticed in lettuce docs that below usage is deprecated
and when i check I have checked the implementation of withAuthentication method and it is as below: /**
* Configures authentication.
*
* @param username the user name
* @param password the **password name**
* @return the builder
* @since 6.0
*/
public Builder withAuthentication(String username, CharSequence password) {
LettuceAssert.notNull(username, "User name must not be null");
LettuceAssert.notNull(password, "Password must not be null");
this.username = username;
return withPassword(password);
} I am not able to understand the String username in parameter list for method withAuthentication . What is it ,and how can we get this/configure this .Is this any random string or sentinel username .if so how can we set/get the sentinel username from config file. Also is passwordname different from password? In specification they have given it as passwordname |
After some help i was able to connect to redis as : RedisClient redisClient = RedisClient.create();
LOG.info("created the redis client");
RedisURI source = RedisURI.Builder
.sentinel(getSentinelHost_1(), getSentinelPort_1())
.withSentinel(getSentinelHost_2(), getSentinelPort_2())
.withSentinel(getSentinelHost_3(), getSentinelPort_3())
.withSentinelMasterId(getMasterName()).withPassword(getMasterPassword())
.build();
for (RedisURI sentinel : source.getSentinels()) {
sentinel.setPassword(getSentinelPassword());
}
StatefulRedisMasterReplicaConnection<String, String> connection = MasterReplica.connect(redisClient, StringCodec.UTF8,
source);
connection.setReadFrom(ReadFrom.REPLICA_PREFERRED);
LOG.info("created the redis connection"); |
Bug Report
Current Behavior
I am trying to connect to the sentinel node of a Redis setup in AWS, and I am getting the message:
Input Code
Just used a template for Spring Boot from
start.spring.io
with redis my properties areExpected behavior/code
It should connect without a problem.
Environment
Possible Solution
I think the problem is that from 5.0.1 and on they added authentication on the Sentinel and that's why it's failing. For more info check Redis 5 Release Notes
The text was updated successfully, but these errors were encountered: