Skip to content

Conversation

@pvaneck
Copy link
Member

@pvaneck pvaneck commented Jan 23, 2026

Ensure the claims are propagated to the MSAL ManagedIdentityClient or, for those credentials not using MSAL, the cache is bypassed when claims are provided so that a new token request is made.

MSAL MI started accepting claims challenges in 1.31.0, so the minimum msal version was bumped. In MSAL, if a claims challenge is passed in, it ensures that a token from the cache isn't returned. Similar logic is adopted for non-MSAL credentials.

Ensure the claims are propagated to the MSAL ManagedIdentityClient
or, for those credentials not using MSAL, the cache is bypassed when
claims are provided so that a new token request is made.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements support for claims challenges in Managed Identity credentials by ensuring that when claims are provided, the token cache is bypassed and claims are properly propagated to the underlying authentication mechanism.

Changes:

  • Bumped minimum msal version from >=1.30.0 to >=1.31.0 to support claims challenges in MSAL's ManagedIdentityClient
  • Updated cache bypass logic in non-MSAL managed identity clients to return None when claims are provided
  • Modified get_cached_token methods to accept and check for claims parameter across sync and async implementations
  • Updated docstrings to reflect that claims are now supported (previously stated they would be ignored)

Reviewed changes

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

Show a summary per file
File Description
pyproject.toml Bumped minimum msal dependency to version 1.31.0 to support claims challenges
azure/identity/_internal/managed_identity_client.py Added cache bypass logic when claims are provided in get_cached_token
azure/identity/_internal/msal_managed_identity_client.py Modified _request_token to pass claims to MSAL's acquire_token_for_client as claims_challenge
azure/identity/_internal/managed_identity_base.py Updated to pass kwargs to get_cached_token for cache bypass support
azure/identity/_credentials/managed_identity.py Updated docstring to document claims parameter support
azure/identity/_credentials/imds.py Modified to pass kwargs through to parent's _request_token
azure/identity/aio/_internal/managed_identity_base.py Updated async version to pass kwargs to get_cached_token
azure/identity/aio/_credentials/managed_identity.py Updated async docstring to document claims parameter support
azure/identity/aio/_credentials/imds.py Updated async version to pass kwargs to get_cached_token
tests/test_managed_identity.py Added test_claims_propagated to verify claims are passed to MSAL's acquire_token_for_client
tests/test_managed_identity_async.py Added test_claims_force_token_refresh to verify cache bypass when claims provided, and test_access_tokens_cached to verify normal caching behavior
CHANGELOG.md Updated bug fix entry and documented msal version bump

@pvaneck pvaneck marked this pull request as ready for review January 23, 2026 23:09
@pvaneck pvaneck requested review from a team and xiangyan99 as code owners January 23, 2026 23:09
@pvaneck pvaneck requested a review from xiangyan99 January 27, 2026 00:04
@pvaneck
Copy link
Member Author

pvaneck commented Jan 27, 2026

/check-enforcer override

@pvaneck pvaneck merged commit d032528 into Azure:main Jan 27, 2026
36 of 37 checks passed
@pvaneck pvaneck deleted the identity-mi-claims branch January 27, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants