-
Notifications
You must be signed in to change notification settings - Fork 3k
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
{KeyVault} Replace _token_retriever
with get_raw_token
#17812
Conversation
def _get_token(cli_ctx, server, resource, scope): # pylint: disable=unused-argument | ||
return Profile(cli_ctx=cli_ctx).get_login_credentials(resource)[0]._token_retriever() # pylint: disable=protected-access | ||
return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0] |
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.
This _get_token
never works because it doesn't comply with KeyVaultAuthentication
's authorization_callback
signature.
Also defer to @houk-ms to fix it in the future.
How about put |
@@ -106,7 +106,7 @@ def create_keyvault_data_plane_client(cli_ctx): | |||
version = str(get_api_version(cli_ctx, ResourceType.DATA_KEYVAULT)) | |||
|
|||
def get_token(server, resource, scope): # pylint: disable=unused-argument | |||
return Profile(cli_ctx=cli_ctx).get_login_credentials(resource)[0]._token_retriever() # pylint: disable=protected-access | |||
return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0] |
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.
Can we make Profile
object a global singleton?
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.
Good suggestion. Will consider doing that in the future.
We will consider to do that when KeyVault data-plane SDK decides to migrate to Track2. Before that, i prefer we keep the original implementation for simplicity. |
Split from #17738
Description
As pointed out by #15854, calling the protected method
_token_retriever
is simply wrong.This PR replaces
_token_retriever
withazure.cli.core._profile.Profile.get_raw_token
, as provided by #15805 (comment).This is also the approach adopted by
azure.cli.command_modules.keyvault._client_factory.keyvault_data_plane_factory
:azure-cli/src/azure-cli/azure/cli/command_modules/keyvault/_client_factory.py
Lines 128 to 137 in 1eed077
On the other hand, instead of implementing its own keyvault client factory, appconfig directly uses
azure.cli.command_modules.keyvault._client_factory.keyvault_data_plane_factory
(#15826):azure-cli/src/azure-cli/azure/cli/command_modules/appconfig/_kv_helpers.py
Lines 300 to 301 in 7a5538f
Other command modules may follow the same approach, but I will defer this decision to @houk-ms.