{Auth} Bring back get_msal_token for acquiring VM SSH certificate#31082
{Auth} Bring back get_msal_token for acquiring VM SSH certificate#31082
get_msal_token for acquiring VM SSH certificate#31082Conversation
️✔️AzureCLI-FullTest
|
|
Hi @jiasli, |
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
| """Get VM SSH certificate. Do not use it for other purposes. To get an access token, use get_raw_token instead. | ||
| """ | ||
| credential, _, _ = self.get_login_credentials() | ||
| certificate_string = credential.get_token(*scopes, data=data).token |
There was a problem hiding this comment.
get_token will be replaces by acquire_token after migrating managed identity authentication to MSAL: #25959
fbc0e05 to
7e9af5d
Compare
| if data is not None: | ||
| from azure.cli.core.azclierror import AuthenticationError | ||
| raise AuthenticationError("VM SSH currently doesn't support managed identity.") |
There was a problem hiding this comment.
This detection was in adal_authentication.MSIAuthenticationWrapper:
It got dropped by #31577 without being migrated to msal_credentials.ManagedIdentityCredential.
get_msal_tokenget_msal_token for acquiring VM SSH certificate
|
As |
Related command
az ssh vmDescription
#19853 removed
Profile.get_msal_tokenand letsshextension callprofile.get_login_credentialsandcredential.get_tokento get the certificate:https://github.com/Azure/azure-cli-extensions/blob/695bd02037a7a8abd6b0ac76ae1ac1559ae46c41/src/ssh/azext_ssh/custom.py#L231-L233
This turns out to be a bad design as
get_tokenis used.get_tokendoesn't supportdataargument at all. This is a CLI-specific extension/alteration.get_token_infoprotocol ({Auth} Supportget_token_infoprotocol #30928),get_tokenis deprecated.This PR brings back
get_msal_token, so thatsshextension can seamlessly switch to the old interface without any update:https://github.com/Azure/azure-cli-extensions/blob/695bd02037a7a8abd6b0ac76ae1ac1559ae46c41/src/ssh/azext_ssh/custom.py#L229
Testing Guide