-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Identity] Enable CAE toggle per token request #30777
Merged
Merged
Conversation
This file contains 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
API change check APIView has identified API level changes in this PR and created following API reviews. |
pvaneck
force-pushed
the
identity-cae-clients
branch
2 times, most recently
from
June 21, 2023 19:59
8297f0a
to
e31f36f
Compare
pvaneck
force-pushed
the
identity-cae-clients
branch
4 times, most recently
from
June 28, 2023 08:30
30bb3c5
to
9a8c432
Compare
pvaneck
force-pushed
the
identity-cae-clients
branch
2 times, most recently
from
July 7, 2023 00:57
51db100
to
4ff7b9e
Compare
pvaneck
force-pushed
the
identity-cae-clients
branch
2 times, most recently
from
July 18, 2023 02:42
3731665
to
d93232f
Compare
@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
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
pvaneck
force-pushed
the
identity-cae-clients
branch
2 times, most recently
from
July 24, 2023 22:14
921223a
to
a258a40
Compare
Does this reply on azure-core change? |
Not necessarily, but would be good to get that one in soon, as well 😄. |
xiangyan99
reviewed
Jul 24, 2023
xiangyan99
reviewed
Jul 25, 2023
sdk/identity/azure-identity/azure/identity/_credentials/silent.py
Outdated
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
xiangyan99
reviewed
Jul 25, 2023
sdk/identity/azure-identity/azure/identity/_internal/shared_token_cache.py
Show resolved
Hide resolved
xiangyan99
reviewed
Jul 25, 2023
xiangyan99
reviewed
Jul 25, 2023
3 tasks
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
pvaneck
force-pushed
the
identity-cae-clients
branch
from
July 27, 2023 00:03
debd26d
to
9fa2acc
Compare
xiangyan99
approved these changes
Jul 27, 2023
This was referenced Aug 3, 2023
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_CP1
env 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_token
call should be able to choose if a CAE-token should be requested or not.Modifications
enable_cae
keyword 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_CP1
environment variable is removed since the behavior of the CP1 capability being "always-on" has been changed.Result
Any
get_token
calls inside aBearerTokenCredentialPolicy
/AsyncBearerTokenCredentialPolicy
can now toggle theenable_cae
flag 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