Support full set of authentication configuration flags#546
Merged
magodo merged 6 commits intoAzure:mainfrom Jul 30, 2024
Merged
Support full set of authentication configuration flags#546magodo merged 6 commits intoAzure:mainfrom
magodo merged 6 commits intoAzure:mainfrom
Conversation
1. Flag `-use-environment-cred` is removed
1. The default credential behavior is:
It attempts to authenticate with each of these credential types, in the following order, stopping when one provides a token:
- ClientSecretCredential
- ClientCertificateCredential
- OIDCCredential
- ManagedIdentityCredential
- AzureCLICredential
1. In terms of provider, the new auth flags have lower precedence than the `-provider-config`
1. `use-managed-identity-cred`, `use-azure-cli-cred`, `use-oidc-cred` are not exclusive, which impact the default credential behavior now (if `false`, it will be skipped)
1. List all the newly added flags
stemaMSFT
reviewed
Jul 29, 2024
Member
stemaMSFT
left a comment
There was a problem hiding this comment.
In theory this makes tons of sense to me. I will let Heng review the code changes in more detail.
This was referenced Aug 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, there are some (though incomplete) authentication related flags, e.g.
--env,--use-azure-cli-cred, these flags only affect the behavior of theaztfexport(e.g. listing resources), but won't be passed through to the providers. The providers' behaviors are only affected by either the-provider-configflag or by the environment of their owns.The reason was there are a bunch of provider level properties (currently there are two providers). It would be a mass if we wrap all these flags and provide a bunch of flags back to users, and probably mentioning which set of flags are only usable for
azurermprovider, and which are only forazapi.However for the standview of the authentication, this separation brings a burden to users who will now need to take care of the two parts:
aztfexportand the provider. It would be much easier for them to regard the both as a whole in terms of authentication. By reviewing the authentication flags betweenazurermandazapi, they are actually quite the same. Based on this, we created this PR to wrap and expose all these authentication related flags, which will affect both theaztfexportand the providers.Changes
The new flags (or existing flags but now passed to providers) are listed below:
envtenant-idauxiliary-tenant-idsclient-idclient-id-file-pathclient-certificateclient-certificate-pathclient-certificate-passwordclient-secretclient-secret-file-pathoidc-request-tokenoidc-request-urloidc-tokenoidc-token-file-pathuse-managed-identity-cred(defaults to false)use-azure-cli-cred(defaults to true)use-oidc-cred(defaults to false)Note that the flags above are following the naming convention as the
azurermprovider. All of them are configurable via environment variables as well, which include the same env var as is defined in theazurermprovider.The default authentication of the
aztfexportwill attempt to authenticate with each of the credential types, in the following order, stopping when one provides a token:If one or more
use-xxx-credis not true, then that credential type will be skipped. This behavior is the same as the provider. This changes the old behavior where when anyuse-xxx-credis specified, it will only use that credential type exclusively. Also note that the old flaguse-environment-credis now removed.The last thing to call out is that the priority of these new auth flags have lower priority than what is defined in the
provider-config, which means users can override any auth config for the provider in theprovider-config. This makes it possible for users to use different credential types between theaztfexportand the provider.Tests
With TF
Without TF
References
Fix #540