-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[App Config] az appconfig: Fix MSI auth for --auth-mode login parameter
#30983
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
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
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>
|
|
AppConfig |
| def test_azconfig_aad_auth(self, resource_group, location): | ||
| aad_store_prefix = get_resource_name_prefix('AADStore') | ||
| config_store_name = self.create_random_name(prefix=aad_store_prefix, length=36) | ||
| config_store_name = self.create_random_name(prefix=aad_store_prefix, length=15) |
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.
Why are we updating name lengths for test resources in this PR?
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.
Also, its 15 here and 24 in other places. If this needs to be updated, can we use the same length for all tests?
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.
We recently split the test into individual files during which we increased the name length to 36 when creating a random name. This however has resulted in some live tests failing as we generated some names that are too long in the case of replicas and keyvault resource. This is being reverted to what they were. In order to avoid delays with merging this fix in, it was included in this PR.
Prior to this change, the length of the store name for this test was 15.
azure-cli/src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_commands.py
Line 3180 in cf83ff0
| config_store_name = self.create_random_name(prefix='AadTest', length=15) |
Not sure if there was a reason for this. Would you suggest we change it to 24 for consistency?
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.
Thanks, yes please change it to 24 for consistency.
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 has been updated, thanks!
|
@zhoxing-ms @yanzhudd , Could you please help merge this fix in? |
az appconfig --auth-mode login: Fix MSI authaz appconfig: Fix MSI auth for --auth-mode login parameter
az appconfig: Fix MSI auth for --auth-mode login parameteraz appconfig: Fix MSI auth for --auth-mode login parameter
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
|
||
| appconfig_credential = AppConfigurationCliCredential(cred, APPCONFIG_AUTH_TOKEN_AUDIENCE) | ||
|
|
||
| self.assertIsInstance(appconfig_credential._impl, MSIAuthenticationWrapper) |
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.
Command modules should not assume the credential type. It is Azure CLI Core's internal implementation. Azure CLI Core only guarantees get_token is implemented.
This change blocks #31092 as cli_ctx is a mock.MagicMock(), forcing cli_ctx.config.getboolean('core', 'use_msal_managed_identity', fallback=False) to be a MagicMock (True). In this case, a CredentialAdaptor is returned, instead of MSIAuthenticationWrapper.
| mock_cmd = mock.MagicMock() | ||
| profile = Profile(cli_ctx=mock_cmd.cli_ctx) |
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.
Why is mock.MagicMock() used as cli_ctx? test_azconfig_credential_adaptor_token_override uses DummyCli() which is correct.
Related command
az appconfig --auth-mode loginDescription
Related to issue #30945
This change ensures that MSI auth works as expected.
Change was tested on azure VM to ensure authentication succeeds.
Since MI testing is not possible to on local dev devices, mocks were used to enable locally testing the code paths that result in
MSIAuthenticationWrapperbeing returned as the credential used for authentication, and was tested to ensure the expected method was called with the right scopes.Testing Guide
History Notes
[App Config]
az appconfig: Fix MSI auth for--auth-mode loginparameterThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.