[PR #218] [MERGED] Add optional Redis username authentication #378

Closed
opened 2026-02-16 01:15:47 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-daemon/pull/218
Author: @taeyoungpark
Created: 4/16/2025
Status: Merged
Merged: 4/25/2025
Merged by: @Yeuoly

Base: mainHead: main


📝 Commits (3)

  • 5fe58fa You can include username for Redis Auth
  • 8b9e28e Redis auth with username - test code update
  • 64bfabc fix: tests

📊 Changes

9 files changed (+20 additions, -17 deletions)

View changed files

📝 internal/cluster/clutser_test.go (+1 -1)
📝 internal/core/persistence/persistence_test.go (+4 -4)
📝 internal/core/plugin_manager/debugging_runtime/connection_key_test.go (+1 -1)
📝 internal/core/plugin_manager/debugging_runtime/server_test.go (+2 -2)
📝 internal/core/plugin_manager/manager.go (+1 -0)
📝 internal/types/app/config.go (+1 -0)
📝 internal/utils/cache/redis.go (+4 -3)
📝 internal/utils/cache/redis_auto_type_test.go (+2 -2)
📝 internal/utils/cache/redis_test.go (+4 -4)

📄 Description

issue #144 related

This pull request introduces support for authenticating Redis connections using both a username and a password. This enhances compatibility with Redis hosting providers like AWS ElastiCache that require username-based authentication in addition to a password.
Motivation:
Modern Redis deployments, particularly managed services like ElastiCache (with RBAC enabled), often mandate the use of a username for authentication alongside the password. The previous implementation only supported password authentication, preventing connections to these types of Redis instances.
Changes:
Configuration: Added a new optional configuration field RedisUser to internal/types/app/config.go, loaded from the REDIS_USERNAME environment variable.
Redis Client: Modified getRedisOptions and InitRedisClient in internal/utils/cache/redis.go to accept and utilize the Username parameter when creating the redis.Options.
Initialization: Updated the Launch function in internal/core/plugin_manager/manager.go to pass the configuration.RedisUser value during Redis client initialization.
Impact:
This change is backward compatible. If the REDIS_USERNAME environment variable is not set or is empty, the client will continue to authenticate using only the password (via the AUTH command).
If REDIS_USERNAME is set, the client will attempt authentication using AUTH .
Introduces the new environment variable REDIS_USERNAME.
How to Test:
Configure the application to connect to a Redis instance requiring username/password auth. Set the REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, and the new REDIS_USERNAME environment variables. Verify the application starts and connects successfully.
Configure the application to connect to a Redis instance requiring only password auth. Set REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD, but do not set REDIS_USERNAME. Verify the application starts and connects successfully.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-daemon/pull/218 **Author:** [@taeyoungpark](https://github.com/taeyoungpark) **Created:** 4/16/2025 **Status:** ✅ Merged **Merged:** 4/25/2025 **Merged by:** [@Yeuoly](https://github.com/Yeuoly) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (3) - [`5fe58fa`](https://github.com/langgenius/dify-plugin-daemon/commit/5fe58faaa89b7d2bf933e8c253808871280c1fb6) You can include username for Redis Auth - [`8b9e28e`](https://github.com/langgenius/dify-plugin-daemon/commit/8b9e28e4cf1226aa7f968c28a926ff08e651b5c0) Redis auth with username - test code update - [`64bfabc`](https://github.com/langgenius/dify-plugin-daemon/commit/64bfabc32cc3ae1a50422f14d6428198e54b79d0) fix: tests ### 📊 Changes **9 files changed** (+20 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `internal/cluster/clutser_test.go` (+1 -1) 📝 `internal/core/persistence/persistence_test.go` (+4 -4) 📝 `internal/core/plugin_manager/debugging_runtime/connection_key_test.go` (+1 -1) 📝 `internal/core/plugin_manager/debugging_runtime/server_test.go` (+2 -2) 📝 `internal/core/plugin_manager/manager.go` (+1 -0) 📝 `internal/types/app/config.go` (+1 -0) 📝 `internal/utils/cache/redis.go` (+4 -3) 📝 `internal/utils/cache/redis_auto_type_test.go` (+2 -2) 📝 `internal/utils/cache/redis_test.go` (+4 -4) </details> ### 📄 Description issue #144 related This pull request introduces support for authenticating Redis connections using both a username and a password. This enhances compatibility with Redis hosting providers like AWS ElastiCache that require username-based authentication in addition to a password. Motivation: Modern Redis deployments, particularly managed services like ElastiCache (with RBAC enabled), often mandate the use of a username for authentication alongside the password. The previous implementation only supported password authentication, preventing connections to these types of Redis instances. Changes: Configuration: Added a new optional configuration field RedisUser to internal/types/app/config.go, loaded from the REDIS_USERNAME environment variable. Redis Client: Modified getRedisOptions and InitRedisClient in internal/utils/cache/redis.go to accept and utilize the Username parameter when creating the redis.Options. Initialization: Updated the Launch function in internal/core/plugin_manager/manager.go to pass the configuration.RedisUser value during Redis client initialization. Impact: This change is backward compatible. If the REDIS_USERNAME environment variable is not set or is empty, the client will continue to authenticate using only the password (via the AUTH <password> command). If REDIS_USERNAME is set, the client will attempt authentication using AUTH <username> <password>. Introduces the new environment variable REDIS_USERNAME. How to Test: Configure the application to connect to a Redis instance requiring username/password auth. Set the REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, and the new REDIS_USERNAME environment variables. Verify the application starts and connects successfully. Configure the application to connect to a Redis instance requiring only password auth. Set REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD, but do not set REDIS_USERNAME. Verify the application starts and connects successfully. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:15:47 -05:00
yindo closed this issue 2026-02-16 01:15:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#378