Skip to content
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

[Enhancement Proposal] User and tenant isolation #15005

Open
jiasli opened this issue Sep 1, 2020 · 5 comments
Open

[Enhancement Proposal] User and tenant isolation #15005

jiasli opened this issue Sep 1, 2020 · 5 comments
Assignees
Milestone

Comments

@jiasli
Copy link
Member

jiasli commented Sep 1, 2020

Issue

Currently, Azure CLI uses subscriptionId as the primary key to distinguish between accounts (stored in ~/.azure/azureProfile.json).

def _get_key_name(account, secondary_key_name):
return (account[_SUBSCRIPTION_ID] if secondary_key_name is None
else '{}-{}'.format(account[_SUBSCRIPTION_ID], account[secondary_key_name]))
def _match_account(account, subscription_id, secondary_key_name, secondary_key_val):
return (account[_SUBSCRIPTION_ID] == subscription_id and
(secondary_key_val is None or account[secondary_key_name] == secondary_key_val))

This causes problem when

  1. az login is run twice with different accounts that have access to the same subscriptions. The subscriptions listed during the second az login will overwrite subscriptions from the first az login.
  2. A subscription can be accessed in multiple tenants. Only the first occurrence is preserved and all subsequent occurrences are discarded. ([Core][Profile] Support lighthouse multi-tenant subscription #11886)
    # When a subscription can be listed by multiple tenants, only the first appearance is retained
    for sub_to_add in subscriptions:
    add_sub = True
    for sub_to_compare in all_subscriptions:
    if sub_to_add.subscription_id == sub_to_compare.subscription_id:
    logger.warning("Subscription %s '%s' can be accessed from tenants %s(default) and %s. "
    "To select a specific tenant when accessing this subscription, "
    "use 'az login --tenant TENANT_ID'.",
    sub_to_add.subscription_id, sub_to_add.display_name,
    sub_to_compare.tenant_id, sub_to_add.tenant_id)
    add_sub = False
    break

Proposal

  1. CLI should use a combined primary key or 3-layer structure which consists of username + tenant_id + subscription_id.
  2. CLI should support switching users with az account set --username.
  3. CLI should support switching tenants with az account set --tenant.
  4. The selected subscription should be saved for each user and each tenant, so that after switching users/tenants, the selected subscription is restored.
@ghost ghost added the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Sep 1, 2020
@yonzhan yonzhan added the Account az login/account label Sep 1, 2020
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Sep 1, 2020
@yonzhan yonzhan added this to the S176 milestone Sep 1, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 1, 2020

login Enhancement

@yonzhan yonzhan modified the milestones: S176, S178 Sep 20, 2020
@yonzhan yonzhan modified the milestones: S178, S179 Oct 24, 2020
@yonzhan yonzhan modified the milestones: S179, S180 Nov 14, 2020
@yonzhan yonzhan modified the milestones: S180, S181 Dec 26, 2020
@yonzhan yonzhan modified the milestones: S181, S182 Jan 15, 2021
@yonzhan yonzhan modified the milestones: S182, S183 Feb 6, 2021
@yonzhan yonzhan modified the milestones: S183 - For Ignite, S184 Feb 26, 2021
@yonzhan yonzhan modified the milestones: S184, S186 Mar 20, 2021
@yonzhan yonzhan modified the milestones: S186, S187 Apr 9, 2021
@miqm
Copy link
Contributor

miqm commented Jan 14, 2022

@yonzhan - any ETA when this will be implemented?

@jiasli
Copy link
Member Author

jiasli commented Jan 14, 2022

Thank you @miqm for your interest in feature. 😊 We will consider this feature in future planning with our PM @chasewilson.

@jiasli
Copy link
Member Author

jiasli commented Jan 17, 2022

Now I more and more prefer keeping the current flattened subscription list and introducing combined primary key which consists of username + tenant_id + subscription_id, like what Azure PowerShell does.

Thus, we can keep the current interface of az account set --subscription. If the subscription can't be uniquely identified, --tenant or --username can be introduced and used.

@cveld
Copy link

cveld commented Jun 14, 2024

@jiasli any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants