-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} Workaround empty and multiple scopes provided by old Track 2 SDKs #15806
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
|
Core |
fengzhou-msft
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.
verified with datashare extension.
| def get_token(self, *scopes, **kwargs): # pylint:disable=unused-argument | ||
| logger.debug("MSIAuthenticationWrapper.get_token invoked by Track 2 SDK with scopes=%s", scopes) | ||
| self.resource = scopes_to_resource(scopes) | ||
| resource = _try_scopes_to_resource(scopes) |
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.
If the resource is None, which resource is used to get token then?
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.
The resource used to create MSIAuthenticationWrapper will be used.
| return MSIAuthenticationWrapper(resource=resource) |
Refine #15184: {Core} Honor
scopesspecified by Track 2 SDKExpected flow
The current Track 2 SDK client takes
credential_scopeswith only one resource as thescopeswhen callingget_token.https://github.com/Azure/azure-sdk-for-python/blob/27e4203818e227ba2604ff52dcf55ce2293c4c37/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py#L60
Issue 1: Empty scopes
Some old Track 2 SDKs generated before Azure/autorest.python#239 don't maintain
credential_scopesand callsget_tokenwith an emptyscopes.https://github.com/Azure/azure-cli-extensions/blob/db8ea65eb4afa9358de39e06a8c37c85e862a61c/src/datashare/azext_datashare/vendored_sdks/datashare/_configuration.py#L61
https://github.com/Azure/azure-cli-extensions/blob/db8ea65eb4afa9358de39e06a8c37c85e862a61c/src/logic/azext_logic/vendored_sdks/logic/_configuration.py#L61
This causes error:
Issue 2: Multiple scopes
Some old Track 2 SDKs generated before Azure/autorest.python#745 extend default
credential_scopeswith customcredential_scopes. Instead,credential_scopesshould be replaced by customcredential_scopes. Azure/azure-sdk-for-python#12947https://github.com/Azure/azure-cli-extensions/blob/120196e953f7b776fa209f4c49838b5cc7af56b0/src/account/azext_account/vendored_sdks/subscription/_configuration.py#L44-L45
Changes
This PR unifies the fixes for the above 2 issues in one function
_try_scopes_to_resource:Testing Guide
⚠ The workarounds only work for now as
get_tokenis implemented by Azure CLI. After migrating to Azure Identity, these workarounds will fail. The old problematic SDKs MUST be regenerated.