Skip to content

Add password support to Redis chat memory autoconfigure#6637

Open
OneZero-Y wants to merge 1 commit into
spring-projects:mainfrom
OneZero-Y:fix/6621-redis-chat-memory-password
Open

Add password support to Redis chat memory autoconfigure#6637
OneZero-Y wants to merge 1 commit into
spring-projects:mainfrom
OneZero-Y:fix/6621-redis-chat-memory-password

Conversation

@OneZero-Y

Copy link
Copy Markdown
Contributor

Fixes #6621

Summary

Redis chat memory autoconfiguration supports host and port, but not password. Users with password-protected Redis instances had to provide their own RedisClient bean instead of using spring.ai.chat.memory.repository.redis.* properties.

This PR adds an optional password property and wires it into the Jedis RedisClient when configured. The legacy spring.ai.chat.memory.redis.* prefix continues to work via delegation.

Changes

  • Add password to RedisChatMemoryRepositoryProperties
  • Apply password when creating RedisClient in RedisChatMemoryRepositoryAutoConfiguration
  • Delegate password in deprecated RedisChatMemoryProperties for the legacy prefix
  • Document spring.ai.chat.memory.repository.redis.password in chat-memory.adoc
  • Add unit tests for password binding with old and new property prefixes

Configuration

spring:
  ai:
    chat:
      memory:
        repository:
          redis:
            host: redis.example.com
            port: 6379
            password: ${REDIS_PASSWORD}

Legacy prefix (still supported):

spring:
  ai:
    chat:
      memory:
        redis:
          password: ${REDIS_PASSWORD}

Test plan

  • ./mvnw -pl auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-redis,auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-redis -am test '-Dtest=RedisChatMemoryAutoConfigurationTests' -Dsurefire.failIfNoSpecifiedTests=false
  • Password binds correctly via spring.ai.chat.memory.repository.redis.password
  • Password binds correctly via legacy spring.ai.chat.memory.redis.password
  • No password configured → existing behavior unchanged

Expose spring.ai.chat.memory.repository.redis.password and wire it into
the Jedis RedisClient when configured. Keep legacy spring.ai.chat.memory.redis
prefix delegation and document the new property.
Fixes spring-projects#6621

Signed-off-by: Bishen Yu <aukovyps@163.com>
@OneZero-Y

Copy link
Copy Markdown
Contributor Author

Hey @dimitarproynov — would you mind taking a look when you get a chance? This adds optional password support to Redis chat memory autoconfigure (spring.ai.chat.memory.repository.redis.password), with the legacy spring.ai.chat.memory.redis.* prefix still delegated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ai : auto redis config : Is possible to add a password in auto config?

2 participants