[Identity] Fix issue with CAE cache not being used - #42145
Merged
Conversation
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
pvaneck
force-pushed
the
identity-cae-kwargs
branch
from
July 22, 2025 02:19
a975ee5 to
07668b0
Compare
pvaneck
marked this pull request as ready for review
July 22, 2025 19:09
pvaneck
requested review from
KarishmaGhiya,
chlowell,
christothes,
maorleger,
minhanh-phan and
scottaddie
July 22, 2025 19:09
Contributor
There was a problem hiding this comment.
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
xiangyan99
approved these changes
Jul 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed an issue where CAE (Continuous Access Evaluation) caches were not properly used by
AuthorizationCodeCredentialand the asynchronousOnBehalfOfCredentialwhen accessing refresh tokens.Closes: #42045