[Identity] Enable CAE toggle per token request#30777
Merged
pvaneck merged 8 commits intoAzure:mainfrom Jul 28, 2023
Merged
Conversation
Collaborator
|
API change check APIView has identified API level changes in this PR and created following API reviews. |
8297f0a to
e31f36f
Compare
30bb3c5 to
9a8c432
Compare
51db100 to
4ff7b9e
Compare
3731665 to
d93232f
Compare
Member
Author
|
@xiangyan99 , Would be great to get a review pass on this 😄 |
xiangyan99
reviewed
Jul 20, 2023
sdk/identity/azure-identity/azure/identity/aio/_credentials/shared_cache.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 20, 2023
sdk/identity/azure-identity/azure/identity/_credentials/silent.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 21, 2023
sdk/identity/azure-identity/azure/identity/_credentials/silent.py
Outdated
Show resolved
Hide resolved
921223a to
a258a40
Compare
Member
|
Does this reply on azure-core change? |
Member
Author
Not necessarily, but would be good to get that one in soon, as well 😄. |
xiangyan99
reviewed
Jul 24, 2023
sdk/identity/azure-identity/azure/identity/_internal/aad_client_base.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
sdk/identity/azure-identity/azure/identity/_credentials/silent.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
sdk/identity/azure-identity/azure/identity/_credentials/silent.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
sdk/identity/azure-identity/azure/identity/_internal/shared_token_cache.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
sdk/identity/azure-identity/azure/identity/_persistent_cache.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
3 tasks
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
Signed-off-by: Paul Van Eck <[email protected]>
debd26d to
9fa2acc
Compare
xiangyan99
approved these changes
Jul 27, 2023
This was referenced Aug 3, 2023
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.
Motivation
Access tokens are typically valid until the time they expire. For more security, Azure AD offers a feature, Continuous Access Evaluation (CAE), that provides near real-time access control where it continuously monitors and re-evaluates user access.
For CAE to work, both the client and resource API must be CAE-enabled. If a resource API implements CAE and a Python SDK declares itself as CAE ready, the client receives CAE tokens for that resource. The client is expected to handle CAE claim challenges that are given. If CAE responses aren't handled, it's possible that an app could end up in a loop of retrying an API call with a token that is still in the returned lifespan of the token but has been revoked due to CAE.
The current design for CAE-enablement in Python SDKs is to always enable CAE by default (mainly just for user-credentials) even if a service isn't CAE-enabled. This is done by adding "CP1" to as an underlying capability to the underlying MSAL application used for authentication. A user can, optionally, globally disable CAE tokens with the
AZURE_IDENTITY_DISABLE_CP1env variable. However, we want to change this design to be more flexible, allowing the same credential instance to get both CAE tokens and non-CAE tokens.Sample scenario: a single application could require talking to five different services/resources. Each of these services may or may not be CAE-enabled. We want to be able to create one credential and use it with all of the service clients, and internally, the service SDK's
get_tokencall should be able to choose if a CAE-token should be requested or not.Modifications
enable_caekeyword argument. This denotes that the token request should include "CP1" client capabilities indicating that the SDK is ready to handle CAE claims challenges..nocae, and the CAE-cache filename will have suffix.cae.AZURE_IDENTITY_DISABLE_CP1environment variable is removed since the behavior of the CP1 capability being "always-on" has been changed.Result
Any
get_tokencalls inside aBearerTokenCredentialPolicy/AsyncBearerTokenCredentialPolicycan now toggle theenable_caeflag depending on if the corresponding service supports CAE or not. This allows more flexibility in when/where CAE tokens are requested/issued.Changelog entry
Corresponding Azure Core PR: #31012
Closes: #26484