Skip to content

[Identity] Fix issue with CAE cache not being used - #42145

Merged
pvaneck merged 1 commit into
Azure:mainfrom
pvaneck:identity-cae-kwargs
Jul 23, 2025
Merged

[Identity] Fix issue with CAE cache not being used#42145
pvaneck merged 1 commit into
Azure:mainfrom
pvaneck:identity-cae-kwargs

Conversation

@pvaneck

@pvaneck pvaneck commented Jul 22, 2025

Copy link
Copy Markdown
Member

Fixed an issue where CAE (Continuous Access Evaluation) caches were not properly used by AuthorizationCodeCredential and the asynchronous OnBehalfOfCredential when accessing refresh tokens.

Closes: #42045

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck
pvaneck force-pushed the identity-cae-kwargs branch from a975ee5 to 07668b0 Compare July 22, 2025 02:19
@pvaneck
pvaneck marked this pull request as ready for review July 22, 2025 19:09
Copilot AI review requested due to automatic review settings July 22, 2025 19:09
@pvaneck
pvaneck requested review from a team and xiangyan99 as code owners July 22, 2025 19:09

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

This PR fixes an issue where CAE (Continuous Access Evaluation) caches were not properly used by AuthorizationCodeCredential and the asynchronous OnBehalfOfCredential when accessing refresh tokens. The fix ensures that the appropriate cache (CAE or regular) is used based on the enable_cae parameter when retrieving cached refresh tokens.

Key changes:

  • Updated both credential classes to pass through kwargs when calling get_cached_refresh_tokens() to respect CAE settings
  • Enhanced test coverage to verify CAE functionality works correctly for both credential types
  • Added proper cache selection logic in tests to validate the correct cache is being used

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
azure/identity/_credentials/authorization_code.py Updated sync AuthorizationCodeCredential to pass kwargs to get_cached_refresh_tokens
azure/identity/aio/_credentials/authorization_code.py Updated async AuthorizationCodeCredential to pass kwargs to get_cached_refresh_tokens
azure/identity/aio/_credentials/on_behalf_of.py Updated async OnBehalfOfCredential to pass kwargs to get_cached_refresh_tokens
tests/test_auth_code.py Enhanced tests with CAE parameterization and cache validation logic
tests/test_obo_async.py Added CAE parameterization to async OnBehalfOfCredential tests
CHANGELOG.md Added changelog entry documenting the CAE cache fix
Comments suppressed due to low confidence (1)

sdk/identity/azure-identity/tests/test_auth_code.py:149

  • [nitpick] The variable name 'cache_being_used' could be more descriptive. Consider renaming it to 'target_cache' or 'selected_cache' to better convey its purpose.
    cache_being_used = cae_cache if enable_cae else cache

@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure Identity SDK Improvements Jul 23, 2025
@pvaneck
pvaneck merged commit b3e716b into Azure:main Jul 23, 2025
29 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Azure Identity SDK Improvements Jul 23, 2025
@pvaneck
pvaneck deleted the identity-cae-kwargs branch July 23, 2025 19:35
Copilot AI mentioned this pull request Jul 28, 2026
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.

Bug: Missing kwargs in get_cached_refresh_tokens causes empty cache with enable_cae=True in _request_token

3 participants