Skip to content

feat: support azure entraid for managed redis - #776

Merged
fatelei merged 2 commits into
langgenius:mainfrom
wylswz:feat/azure-managed-identity
Jul 23, 2026
Merged

feat: support azure entraid for managed redis#776
fatelei merged 2 commits into
langgenius:mainfrom
wylswz:feat/azure-managed-identity

Conversation

@wylswz

@wylswz wylswz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Support EntraID for azure managed Redis
resolves ESQ1-184

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Please provide any additional context that would help reviewers understand the changes.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request go Pull requests that update go code labels Jul 23, 2026
@dosubot

dosubot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📄 Knowledge review

✏️ Documentation updates

1 page was updated by changes in this PR.

Page Library Status
cache /dify-plugin-daemon/blob/main/docs/claude/cache.md dify-plugin-sdks ✅ Updated
📝 cache — changes
@@ -105,11 +105,38 @@
 ```go
 cache.InitRedisClient(
     addr,      // "localhost:6379"
-    username,  // optional
-    password,  
+    cache.RedisCredentials{
+        Username: username,  // optional
+        Password: password,
+    },
     useSsl,    // bool
     db,        // database number
+    tlsConf,   // *tls.Config, can be nil
 )
+```
+
+### Azure Entra ID Authentication
+
+The daemon supports Azure Managed Identity (Entra ID) for Redis authentication.
+This is configured using the `REDIS_USE_AZURE_MANAGED_IDENTITY` environment variable.
+When enabled, static `REDIS_PASSWORD`/`REDIS_USERNAME` are ignored and a streaming
+token provider is used instead. Azure Managed Redis requires `REDIS_DB=0` (the system
+validates this at startup).
+
+```go
+creds := cache.RedisCredentials{
+    Username: username,
+    Password: password,
+}
+if useAzureManagedIdentity {
+    provider, err := cache.NewAzureEntraIDCredentialsProvider()
+    if err != nil {
+        // handle error
+    }
+    creds.CredentialProvider = provider
+}
+
+cache.InitRedisClient(addr, creds, useSsl, db, tlsConf)
 ```
 
 Redis naming behavior:

Leave Feedback Ask Dosu about dify-plugin-daemon

@wylswz wylswz changed the title feat: support azure mi feat: support azure entraid for managed redis Jul 23, 2026
@wylswz
wylswz requested a review from Copilot July 23, 2026 04:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for authenticating to Azure Cache for Redis using Entra ID (Managed Identity) by introducing streaming credential support in the Redis client initialization path, and wiring it through configuration and startup.

Changes:

  • Introduces RedisCredentials and passes a StreamingCredentialsProvider into go-redis options/failover options to enable token-based auth.
  • Adds an Azure Entra ID credentials provider factory and a new env/config flag (REDIS_USE_AZURE_MANAGED_IDENTITY) with validation (DB must be 0).
  • Updates all Redis-related tests and call sites to use the new InitRedisClient/InitRedisSentinelClient signatures.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/utils/cache/redis.go Adds RedisCredentials and wires streaming credentials into redis options.
pkg/utils/cache/azure_credentials.go Implements Azure Entra ID (Managed Identity) streaming credentials provider creation.
internal/types/app/config.go Adds config flag and validates Redis DB constraints for Azure managed identity.
internal/core/plugin_manager/manager.go Builds Redis credentials and initializes Redis client/sentinel with new credentials API.
pkg/utils/cache/redis_test.go Updates tests to use RedisCredentials with the new init signature.
pkg/utils/cache/redis_auto_type_test.go Updates tests to use RedisCredentials with the new init signature.
internal/types/models/curd/testmain_test.go Updates Redis init in test main to use RedisCredentials.
internal/service/plugin_decoder_test.go Updates Redis init in test setup to use RedisCredentials.
internal/service/debugging_service/connection_key_test.go Updates Redis init to use RedisCredentials.
internal/core/session_manager/session_trace_test.go Updates Redis init to use RedisCredentials.
internal/core/persistence/persistence_test.go Updates Redis init to use RedisCredentials.
internal/core/debugging_runtime/server_test.go Updates Redis init to use RedisCredentials (plus minor whitespace cleanup).
internal/cluster/clutser_test.go Updates Redis init to use RedisCredentials.
go.mod Adds github.com/redis/go-redis-entraid and bumps Azure identity dependency.
go.sum Adds checksums for new/bumped dependencies.
.env.example Documents the new Azure managed identity Redis auth flag and constraints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/utils/cache/redis.go Outdated
Comment thread internal/core/plugin_manager/manager.go
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 23, 2026
@fatelei
fatelei merged commit 18da218 into langgenius:main Jul 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants