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] Support "bring your own access token" #16459

Open
jiasli opened this issue Jan 8, 2021 · 8 comments
Open

[Enhancement Proposal] Support "bring your own access token" #16459

jiasli opened this issue Jan 8, 2021 · 8 comments
Assignees
Milestone

Comments

@jiasli
Copy link
Member

jiasli commented Jan 8, 2021

Is your feature request related to a problem? Please describe.

We have received several feature requests that the user would like to provide their own access token, without interacting with AAD.

Azure PowerShell cmdlet Connect-AzAccount supports -AccessToken.

Describe the solution you'd like

  1. az login should support either

  2. Each az command should support a global argument --access-token which can be used together with --subscription to invoke ARM request:

    az group list --access-token <access_token> --subscription <subscription_id>
    

    I previously made a prototype: [Demo] Allow specifying a custom access token jiasli/azure-cli#12

  3. Consume an environment variable AZURE_CLI_ACCESS_TOKEN so that all commands can use the same access token:

    export AZURE_CLI_ACCESS_TOKEN=<access_token>
    az group list
    

    Also, since environment variables are preserved in memory, is it much safer than saving the access token to hard disk. Also see Enable authentication via environment variables #10241

@ghost ghost added the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jan 8, 2021
@yonzhan
Copy link
Collaborator

yonzhan commented Jan 8, 2021

Enhancement Proposal

@yonzhan yonzhan added the Account az login/account label Jan 8, 2021
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jan 8, 2021
@yonzhan yonzhan added this to the S182 milestone Jan 8, 2021
@jiasli
Copy link
Member Author

jiasli commented Jan 15, 2021

Azure CLI can take advantage of TokenCredential if Azure/azure-sdk#2189 is implemented.

@richeney
Copy link

That would be cool. especially if those --subscription and --access-token switches supported Azure defaults. You could then set env vars, e.g. export AZURE_DEFAULTS_ACCESS_TOKEN=$mytoken.

I often have scrips that export AZURE_DEFAULTS_LOCATION and AZURE_DEFAULTS_GROUP to save including --location and --resource-group on every CLI command.

@bganapa
Copy link
Member

bganapa commented Mar 25, 2022

If you are looking for this option to run few cli commands parallelly with different user context, the option of AZURE_CONFIG_DIR may be helpful
https://docs.microsoft.com/en-us/cli/azure/use-cli-effectively#concurrent-builds

@jiasli
Copy link
Member Author

jiasli commented Apr 24, 2024

Limitations

  1. The access token usually expires after 1 hour. Users will have to log in again after it expires.
  2. The access token has a specific audience claim (aud), which means it can only be used on one resource. For example, if an ARM's access token is provided, Storage or Key Vault data-plane commands will fail as the audience doesn't match the resource.
  3. Directly manipulating access tokens is risky and can lead to credential leak.

@ayanamist
Copy link

@hcoona
Copy link

hcoona commented Jun 21, 2024

We understand the limitation and we confirm our scenario need this feature.

  1. We are C# service and can acquire OBO AT. We need to execute user's instruction by passing some parameters to Azure CLI. We know the best approach is to construct deployment ARM template but currently we cannot because of the flexible requirements.
  2. We sometime want to go across the Docker container boundary. AKA. generate the AT outside but execute it inside the container.

@fl0mb
Copy link

fl0mb commented Oct 11, 2024

Any updates on this?

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

7 participants