Skip to content

redis: add credentials provider option and built-in Entra ID auth - #1626

Open
cosmin-staicu wants to merge 1 commit into
livekit:mainfrom
UiPath:feat/redis-entra-credentials-provider
Open

cosmin-staicu wants to merge 1 commit into
livekit:mainfrom
UiPath:feat/redis-entra-credentials-provider

Conversation

@cosmin-staicu

@cosmin-staicu cosmin-staicu commented Jun 15, 2026 •

Copy link
Copy Markdown

Adds support for rotated Redis credentials to GetRedisClient, through a vendor-neutral WithStreamingCredentialsProvider option and a config-driven azure_entra flag for Microsoft Entra ID. Existing callers and YAML are unaffected.

Why

GetRedisClient only accepts a static Username/Password. That doesn't work with managed Redis offerings that authenticate with short-lived identity tokens. Azure Managed Redis and Redis Enterprise Cloud issue Microsoft Entra ID tokens that expire after about an hour and have to be refreshed and re-AUTH'd on the live connection before they lapse.

With static credentials, a long-running deployment is disconnected when the token expires. The pub/sub bus is hit hardest. Managed Redis evicts a pub/sub connection when its token expires, and under RESP2 a pub/sub socket can't process an out-of-band AUTH, so it has to reconnect with a fresh token. Every component that builds its client through this package (server, sip, egress, ingress) is affected.

What

go-redis has supported this through StreamingCredentialsProvider since v9.6 (this module is on v9.22.0), and Redis publishes an official Entra ID provider, go-redis-entraid. This PR exposes it two ways:

  • WithStreamingCredentialsProvider(p), a variadic option on GetRedisClient for callers that bring their own provider.
  • RedisConfig.azure_entra, a YAML flag that builds a go-redis-entraid provider from the ambient Azure identity (DefaultAzureCredential), so a deployment can turn it on in config without a call site of its own.

An explicit provider takes precedence over the flag. With neither set, the client is built exactly as before. Building the options moved into buildRedisOptions, so it can be tested without a Redis server.

go.mod gains go-redis-entraid, with azidentity and MSAL as indirect dependencies.

Tests in redis/redis_test.go cover a client with no provider, an explicit provider, the flag, and an explicit provider winning over the flag.

@changeset-bot

changeset-bot Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25c44a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
github.com/livekit/protocol Patch
@livekit/protocol Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant

CLAassistant commented Jun 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cosmin-staicu
cosmin-staicu force-pushed the feat/redis-entra-credentials-provider branch from 63e17d0 to 3135f36 Compare August 4, 2026 14:27
@cosmin-staicu
cosmin-staicu force-pushed the feat/redis-entra-credentials-provider branch from 3135f36 to e227b1a Compare August 19, 2026 13:19
@cosmin-staicu
cosmin-staicu force-pushed the feat/redis-entra-credentials-provider branch from 9867e3b to a0a06fb Compare September 10, 2026 08:11
@cosmin-staicu

Copy link
Copy Markdown
Author

Rebased onto current main (was conflicting) and split: this PR is now the redis commit alone, with a changeset added.

The log-config-watch work that had crept onto this branch has moved to #1791, which is stacked on this one.

GetRedisClient only accepted a static Username/Password, which does not work
with managed Redis offerings that authenticate with short-lived identity
tokens. Azure Managed Redis and Redis Enterprise Cloud issue Microsoft Entra ID
tokens that expire after roughly an hour and have to be refreshed and re-AUTH'd
on the live connection before they lapse. Managed Redis evicts a pub/sub
connection when its token expires and, under RESP2, a pub/sub socket cannot
process an out-of-band AUTH, so it has to reconnect with a fresh token — which
hits the coordination bus every component built on this module relies on.

go-redis has supported this since v9.6 through StreamingCredentialsProvider.
Expose it two ways:

- WithStreamingCredentialsProvider, a vendor-neutral option for callers that
  bring their own provider.
- RedisConfig.azure_entra, a config-driven flag that builds a provider from
  github.com/redis/go-redis-entraid off the ambient Azure identity, so a
  deployment turns this on in YAML without its own call site.

Both are additive: GetRedisClient keeps its existing signature for callers that
pass no options, and existing YAML is unaffected.

Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>
@cosmin-staicu
cosmin-staicu force-pushed the feat/redis-entra-credentials-provider branch from a0a06fb to 25c44a2 Compare September 24, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants