-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Keyvault} Remove useless AAD endpoint and honor user input --subscription to support cross sub operations
#26539
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -401,15 +401,14 @@ def recover_vault_or_hsm(cmd, client, resource_group_name=None, location=None, v | |||||
|
|
||||||
|
|
||||||
| def recover_hsm(cmd, client, hsm_name, resource_group_name, location, no_wait=False): | ||||||
| from azure.cli.core._profile import Profile | ||||||
| from azure.cli.core._profile import Profile, _TENANT_ID | ||||||
|
|
||||||
| ManagedHsm = cmd.get_models('ManagedHsm', resource_type=ResourceType.MGMT_KEYVAULT) | ||||||
| ManagedHsmSku = cmd.get_models('ManagedHsmSku', resource_type=ResourceType.MGMT_KEYVAULT) | ||||||
|
|
||||||
| # tenantId and sku shouldn't be required | ||||||
| profile = Profile(cli_ctx=cmd.cli_ctx) | ||||||
| _, _, tenant_id = profile.get_login_credentials( | ||||||
| resource=cmd.cli_ctx.cloud.endpoints.active_directory_graph_resource_id) | ||||||
|
Comment on lines
-411
to
-412
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is indeed why a token for AD Graph is retrieved. class MSIAuthentication(BasicTokenAuthentication):
def __init__(self, port=50342, **kwargs):
....
self.set_token()When This behavior will be changed in #25959 in order to align with other MSAL-based credentials -
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another question, why does the original code choose Update: Well. It looks like #3631 simply copied the code for creating AD Graph client but only kept the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This explains why AAD call shows up when we create keyvault in Cloudshell sandbox as it's following MSI workflow.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anyway the whole call for |
||||||
| tenant_id = profile.get_subscription(subscription=cmd.cli_ctx.data['subscription_id'])[_TENANT_ID] | ||||||
|
|
||||||
| # Use 'Recover' as 'create_mode' temporarily since it's a bug from service side making 'create_mode' case-sensitive | ||||||
| # Will change it back to CreateMode.recover.value('recover') from SDK definition after service fix | ||||||
|
|
@@ -426,7 +425,7 @@ def recover_hsm(cmd, client, hsm_name, resource_group_name, location, no_wait=Fa | |||||
|
|
||||||
|
|
||||||
| def recover_vault(cmd, client, vault_name, resource_group_name, location, no_wait=False): | ||||||
| from azure.cli.core._profile import Profile | ||||||
| from azure.cli.core._profile import Profile, _TENANT_ID | ||||||
|
|
||||||
| VaultCreateOrUpdateParameters = cmd.get_models('VaultCreateOrUpdateParameters', | ||||||
| resource_type=ResourceType.MGMT_KEYVAULT) | ||||||
|
|
@@ -436,8 +435,7 @@ def recover_vault(cmd, client, vault_name, resource_group_name, location, no_wai | |||||
| Sku = cmd.get_models('Sku', resource_type=ResourceType.MGMT_KEYVAULT) | ||||||
| SkuName = cmd.get_models('SkuName', resource_type=ResourceType.MGMT_KEYVAULT) | ||||||
| profile = Profile(cli_ctx=cmd.cli_ctx) | ||||||
| _, _, tenant_id = profile.get_login_credentials( | ||||||
| resource=cmd.cli_ctx.cloud.endpoints.active_directory_graph_resource_id) | ||||||
| tenant_id = profile.get_subscription(subscription=cmd.cli_ctx.data['subscription_id'])[_TENANT_ID] | ||||||
|
||||||
| scope = _build_role_scope(resource_group_name, scope, | |
| definitions_client._config.subscription_id) |
Let me think how we can improve this hack from core level.
Uh oh!
There was an error while loading. Please reload this page.