-
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
[Core] Add CAE flag to auth policies #31012
Conversation
API change check APIView has identified API level changes in this PR and created following API reviews. |
a05728c
to
22954c2
Compare
This enables users and client SDKs to pass in a flag to denote that `get_token` requests should be requesting CAE tokens. If the underlying credential's `get_token` implementation supports this flag, then a CAE token will be requested. Otherwise, a non-CAE token will be requested. 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>
sdk/core/azure-mgmt-core/azure/mgmt/core/policies/_authentication.py
Outdated
Show resolved
Hide resolved
- This also adjusts test token credential `get_token` methods to accept kwargs if they do not. 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>
When using |
This first adds a keyword argument to the TokenCredential protocol method `get_token`. This enables users and client SDKs to pass in a flag to denote that `get_token` requests should be requesting CAE tokens. If the underlying credential's `get_token` implementation supports this flag, then a CAE token will be requested. Otherwise, a non-CAE token will be requested. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> (cherry picked from commit a7519f9)
* Code refactored as per main * Fixed issues * Fixed testcases * Reverted play_media_to_all changes * Updated readme as per latest changes * [Core] Add CAE flag to auth policies (#31012) This first adds a keyword argument to the TokenCredential protocol method `get_token`. This enables users and client SDKs to pass in a flag to denote that `get_token` requests should be requesting CAE tokens. If the underlying credential's `get_token` implementation supports this flag, then a CAE token will be requested. Otherwise, a non-CAE token will be requested. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> (cherry picked from commit a7519f9) * fix tests (#31526) * fix tests * update (cherry picked from commit d1d0ef6) * Packaging update of azure-mgmt-azureadb2c --------- Co-authored-by: Paul Van Eck <paulvaneck@microsoft.com> Co-authored-by: Xiang Yan <xiangsjtu@gmail.com> Co-authored-by: Azure SDK Bot <adxpysdk@microsoft.com>
Thank you for reporting the issue. Could you share the version of azure-cli you are using? And if possible, the version of azure-keyvault package? |
The azure-cli was freshly installed via pipx in version 2.51.0. This installed dependency azure-core was in version 1.29.0 and azure-keyvault in version 1.1.0. As I said, manually downgrading azure-core to version 1.28.0 mitigated the problem. |
This assumption is unfortunately not true for Azure CLI and caused breakage in Azure CLI as shown in the above comment #31012 (comment) and Azure/azure-cli#27131. Azure CLI also implements def get_token(self, *scopes, claims=None, **kwargs):
...
result = self.acquire_token_silent_with_error(list(scopes), self._account, claims_challenge=claims, **kwargs) The only exception is def get_token(self, *scopes, **kwargs):
...
# SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
# so discard it.
kwargs.pop('tenant_id', None) The popping |
The
get_token
protocol is updated to allow an optionalenable_cae
keyword argument. The overall signature doesn't change as we just document thatenable_cae
can be passed in as a part ofkwargs
.With the flag, we can enable users and client SDKs to speciify that
get_token
requests should be requesting CAE-enabled tokens.If the underlying credential's
get_token
implementation supports this flag, then a CAE-enabled token should be requested. Otherwise, a non-CAE token should be requested.In this PR
BearerTokenCredentialPolicy
andAsyncBearerTokenCredentialPolicy
are updated to also allow anenable_cae
keyword argument in the constructors. This will be used in determining ifenable_cae
should be used in their respectiveget_token
requests.Since, ARM supports CAE and has logic for handling these CAE claims challenges,
ARMChallengeAuthenticationPolicy
andAsyncARMChallengeAuthenticationPolicy
were updated to ensure thatenable_cae
is set toTrue
. Edit: This will be split out into a separate PRMore info here: #30777
Notes
get_token
implementations across our SDKs take in**kwargs
, soenable_cae
being passed in shouldn't cause any breakage. If needed, we can always catch TypeErrors for unexpected keyword arguments.