-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
RedisConnectionFactory with IAM auth for Elasticache #2769
Comments
What client are you using? Jedis uses a fixed password while Lettuce provides a Credentials Supplier API that you can use without subclassing any Spring Data Redis utilities. |
@mp911de thanks for your response. We're using Lettuce. How can I use credentials supplier API while creating LettuceConnectionFactory? Kindly suggest. |
You have to provide a class MyCredentialsProviderFactory implements RedisCredentialsProviderFactory {
@Override
public RedisCredentialsProvider createCredentialsProvider(RedisConfiguration redisConfiguration) {
Supplier<RedisCredentials> supplier = …;
return () -> Mono.fromSupplier(supplier);
}
@Override
public RedisCredentialsProvider createSentinelCredentialsProvider(RedisSentinelConfiguration redisConfiguration) {
Supplier<RedisCredentials> supplier = …;
return () -> Mono.fromSupplier(supplier);
}
}
LettuceClientConfiguration clientConfiguration = LettuceClientConfiguration.builder()
.redisCredentialsProviderFactory(new MyCredentialsProviderFactory())
.build();
LettuceConnectionFactory connFactory = new LettuceConnectionFactory(redisConfiguration, clientConfiguration); |
@mp911de thanks for sharing the code snippet.. We're currently using springboot 2.7 and RedisCredentialsProviderFactory is not present in 2.7.11 |
|
@mp911de We migrated to Java 17 and Springboot 3.1.5 but still facing the same issue. ` class IamCredentialsProviderFactory implements RedisCredentialsProviderFactory {
|
This captures the password that has been created and each request to provide new credentials returns the same password. You need to return the password within the |
Thanks! I'll try this today and confirm |
Hi,
We recently switched from Password based Auth to IAM auth for our Elasticache cluster enabled Redis. I was able to supply Sig4 signed request as password and connect to Elasticache. This works well for first 12 hours as IAM auth enabled Elasticache disconnects after 12 hours automatically.
As I created a Custom RedisClusterConfiguration while creating RedisConnectionFactory so was expecting Springboot-data-redis and Lettuce to reconnect automatically but it seems like the password / "Sig4 signed request" that was generated for the first time is being cached somewhere.
Here is my code.... I don't see getPassword() being called while trying to reconnect.. I'm getting WRONG username - password error in Logs.
Any thoughts how we can supply new password (generated through code) every time it tries to retry connecting to Redis.
Thanks for taking a look at this.
Thanks,
Chandan
The text was updated successfully, but these errors were encountered: