-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Adds a fallback mechanism to AAD scope override. #42731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 PR introduces a fallback mechanism for AAD scope override in the Azure Cosmos DB client. When no override scope is provided, the client will first attempt authentication with the account scope, and if that fails with the specific error AADSTS500011, it will fallback to the default Cosmos scope https://cosmos.azure.com/.default. The fallback only occurs when using account scope - when an override scope is explicitly provided, no fallback occurs.
Key changes:
- Modified authentication policy classes to support fallback logic with retry mechanism
- Updated client connection initialization to pass both account and override scopes to the policy
- Enhanced test coverage with comprehensive scenarios for scope override and fallback behavior
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/cosmos/azure-cosmos/azure/cosmos/_auth_policy.py |
Implements fallback logic in sync authentication policy with retry loop for AADSTS500011 errors |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_auth_policy_async.py |
Implements fallback logic in async authentication policy with retry loop for AADSTS500011 errors |
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py |
Updates sync client initialization to pass separate account and override scopes to the policy |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py |
Updates async client initialization to pass separate account and override scopes to the policy |
sdk/cosmos/azure-cosmos/tests/test_aad.py |
Adds comprehensive sync test coverage for scope override and fallback scenarios |
sdk/cosmos/azure-cosmos/tests/test_aad_async.py |
Adds comprehensive async test coverage for scope override and fallback scenarios |
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
22b491f to
e4e0904
Compare
tvaron3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
|
/azp run python - cosmos - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
FabianMeiswinkel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
It's a follow up to this PR #42228, which introduces the ability to override AAD scope value. As part of the current PR:
This is a temporary change we are implementing till this "https://cosmos.azure.com/.default" is accepted as the scope across all environments and clouds.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines