feat: add ability to auth to azure with token - #27556
feat: add ability to auth to azure with token#27556oss-pr-review-agent-shin[bot] merged 6 commits into
Conversation
Mirrors the system-message skip in PR #25481 for tool-role messages. Adds a global litellm.skip_tool_message_in_guardrail flag and a per-guardrail litellm_params.skip_tool_message_in_guardrail override, applied in the OpenAI and Anthropic chat translation handlers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a tri-state control (inherit / yes / no) when creating or editing guardrails so admins can set litellm_params.skip_tool_message_in_guardrail without YAML, mirroring the existing skip_system_message control. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…guardrails feat(guardrails): optional skip tool message in unified guardrail inputs
Cherry-pick of PR #21764 — adds Azure AD token authentication for Redis, adapted to coexist with the existing GCP IAM credential provider refactor on this branch. Adds `_generate_azure_ad_redis_token`, `_build_azure_credential`, and `create_azure_ad_redis_connect_func`, threads Azure AD config through sync, async, async cluster, and connection pool paths, and includes unit tests for the helpers and `_get_redis_client_logic` setup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds Azure AD (Entra ID) token-based authentication for Redis, bringing parity with the existing GCP IAM auth flow. Users can set
Confidence Score: 5/5Safe to merge; the new auth paths are additive and only activate when the Azure AD flag is explicitly set, leaving all existing Redis configurations untouched. The change is purely additive — Azure AD auth is gated behind an opt-in flag and does not alter any existing code paths. All three async paths correctly delegate to AzureADCredentialProvider so tokens refresh transparently. Tests mock the Azure Identity SDK and cover DefaultAzureCredential, ClientSecretCredential, and import-error paths without real network calls. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/_redis.py | Adds Azure AD token-based Redis authentication: _build_azure_credential, create_azure_ad_redis_connect_func, and integration in _get_redis_client_logic, get_redis_async_client, and get_redis_connection_pool. All async paths correctly delegate to AzureADCredentialProvider so the Azure SDK handles silent refresh. Minor duplication of AZURE_REDIS_SCOPE with _redis_credential_provider.py. |
| litellm/_redis_credential_provider.py | Adds AzureADCredentialProvider implementing CredentialProvider for Azure AD token-based Redis auth. Mirrors GCPIAMCredentialProvider pattern; correctly offloads the blocking get_token call to a thread in get_credentials_async. |
| tests/test_litellm/test_utils.py | Adds four unit tests for Azure AD Redis auth. All tests mock azure.identity via patch.dict("sys.modules", ...), making them self-contained and CI-safe without requiring the real azure-identity package. No real network calls. |
Reviews (2): Last reviewed commit: "chore(lint): silence PLR0915 on _get_red..." | Re-trigger Greptile
Azure AD Redis credential refresh addedThis PR adds Azure AD credential support for Redis and routes the async cluster, standard async client, and async connection-pool paths through Redis credential providers so tokens are fetched per connection rather than baked into long-lived clients. I checked the surrounding Redis initialization paths and did not find a security issue in the changed code. Status: 0 open · 1 resolved |
Address review issues on PR #21764 cherry-pick: - Add AzureADCredentialProvider that wraps the live azure-identity credential, so async cluster, async standard, and connection-pool paths fetch tokens via the SDK's internal cache + silent refresh on every connection — instead of baking a single point-in-time token as the password (which would expire ~1h after pool creation and break all subsequent reconnects). - Stop attaching raw client_id / tenant_id / client_secret to the redis_connect_func object. The credential closure already holds them; exposing them as function attributes risked leaks via inspection or logging. Async paths now read the already-built credential object via `_azure_credential` instead. - Connection-pool path now picks up REDIS_USERNAME for ACL-configured Azure Redis instances, matching the cluster + async paths. - Mock azure.identity via sys.modules in test_redis_client_logic_ azure_ad_auth so the test no longer requires azure-identity to be installed in the CI environment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The function is structured around a long sequence of optional configuration probes (sentinel/cluster/GCP/Azure) and breaking it up just to satisfy the statement count would split related logic. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@greptileai review again |
c7739c9
into
shin_agent_oss_staging_05_09_2026
|
🤖 litellm-agent: Squash-merged into staging branch Triage Summary Merge Confidence: 5/5 ✅ READY All checks green. Greptile 5/5, no blocking pattern findings, CircleCI passed. |
Squash-merged by litellm-agent from shivamrawat1's PR.
Resolves LIT-1735
Description
Adds Azure AD (Entra ID) passwordless authentication for LiteLLM's Redis cache, mirroring the
existing GCP IAM support. Sync clients, async clients, async clusters, and async connection pools
all authenticate via the azure-identity SDK and refresh tokens silently before the ~1h TTL expires.
Supports DefaultAzureCredential, ManagedIdentityCredential, and ClientSecretCredential selection
based on which env vars are set.
Enable with REDIS_AZURE_AD_TOKEN=true plus AZURE_CLIENT_ID / AZURE_TENANT_ID / AZURE_CLIENT_SECRET
(or rely on workload identity / managed identity discovery).
Cause
LiteLLM's existing Redis auth supported only static passwords or GCP IAM. Operators running Azure
Cache for Redis with AAD auth (a hard requirement on many Azure environments — Microsoft has been
pushing customers off shared keys) had no first-class way to wire it up. Several attempts in the
wild were patching this in via redis_connect_func themselves, with two recurring footguns:
expires after ~1 hour, after which every new connection out of the pool fails authentication —
silently bricking caching workloads. This is what the original PR feat: add ability to auth to azure with token #21764 shipped, and what the
review caught.
_azure_client_id / _azure_tenant_id / _azure_client_secret directly on redis_connect_func so async
paths could read them back — exposing the secret to anything that inspects, serialises, or logs the
function object.
There was also no test coverage that worked without azure-identity installed, no REDIS_USERNAME
propagation in the pool path (breaking ACL-configured Azure Redis instances), and
_get_redis_client_logic tripped Ruff's PLR0915 once the new branches were added.
Fix
azure-identity credential. It implements redis.credentials.CredentialProvider and is invoked
per-connection by redis-py, so the SDK's internal token cache + silent refresh apply to async
cluster, async standard, and BlockingConnectionPool paths. No more static-token-baked-in-pool
expiry.
reconnects via the function's closure. Attaches the built credential object (_azure_credential) —
not the raw inputs — for async paths to discover.
azure_redis_ad_token = True for detection, and strips the four azure* kwargs before they hit the
redis-py constructors. GCP IAM takes precedence if both are configured (with a warning).
credential provider, so ACL-configured Azure Redis instances connect cleanly.
tests cover the helpers, ImportError, service-principal selection, and that raw secrets are not
exposed on the function.
config probes — splitting it would just scatter related logic).
Files: litellm/_redis.py (+219), litellm/_redis_credential_provider.py (+35),
tests/test_litellm/test_utils.py (+122).