micronaut-redis icon indicating copy to clipboard operation
micronaut-redis copied to clipboard

password is not passed

Open rost5000 opened this issue 2 years ago • 4 comments

Expected Behavior

Class AbstractRedisClientFactory has the method public RedisClient redisClient(AbstractRedisConfiguration config, @Nullable ClientResources optionalClientResources, @Nullable List<ClientResourcesMutator> mutators) { //... . The method have the following expression: Optional<RedisURI> uri = config.getUri(); The problem is that password is not copied, when I configured in application.yaml For example:

redis:
  uri: redis://localhost
  password: bla-bla

So I receive error: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.

Actual Behaviour

I expect that config.getUri(); return the password writed in application.yaml

Steps To Reproduce

  1. Clone https://github.com/rost5000/demo-lettuce-micronaut-bug
  2. Run docker-compose up -d
  3. Run micronaut application
  4. Go to http://localhost:8080/health
  5. You can see the following string in console: My Password from application.yaml: null. It is not expected password that I wrote.

Environment Information

  • Windows 10
  • Jdk 17 graalvm

Example Application

https://github.com/rost5000/demo-lettuce-micronaut-bug

Version

v3.5.1

rost5000 avatar Jun 08 '22 23:06 rost5000

it is my understanding that the password has to be included as part of the Redis URI. See https://lettuce.io/core/release/api/io/lettuce/core/RedisURI.html for the syntax

graemerocher avatar Jul 08 '22 07:07 graemerocher

@graemerocher graemerocher, Yes its true, however, considering the documentation: https://lettuce.io/core/release/reference/#connecting-redis I can use separately password and URL. Does Micronaut-Redis support that feauter?

Now I should replace bean in micronaut by this:

    @Bean
    @Replaces
    @Primary
    public RedisClient redisClient(AbstractRedisConfiguration configuration) {
        return RedisClient.create(configuration);
    }

Information about password is set in AbstractRedisConfiguration when I set like this

rost5000 avatar Jul 12 '22 08:07 rost5000

@graemerocher The document just said:You can customize the Redis configuration using any properties exposed by the DefaultRedisConfiguration class. And the password is the public property(though it's deprecated.). Maybe,as a habit of many developers,we should support the password property?

dev2007 avatar Apr 10 '23 06:04 dev2007

Are there any updates on this issue, please? It still seems not possible to specify the password separate from the URI.

Since we are running the application in Kubernetes, I would like to specify the password from a Kubernetes Secret and it's available as an environment variable. If it has to be passed as part of the RedisURI in the application.yml, which is also a separate environment variable, it's not easy to combine these in the YAML file.

aseychell avatar May 23 '24 08:05 aseychell