-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#4343) This change adds `azure-pipelines` as a supported value for the `--federated-credential-provider` switch of `azd auth login`. This provider can be used to do OIDC based login within the context of a job running in Azure Pipelines. When using this provider, `azd` uses the `AzurePipelinesCredential` type to manage the OIDC dance. In addition to the client and tenant id of the service principal you plan to authenticate with, we also need the "service connection id" (this is the ID of the object created in Azure Pipelines that contains the connection information) and the system access token which is the security token for the running build (it's what is used to authenticate to the OIDC endpoint that is being run inside the pipeline which we use to fetch the federated credential). The client and tenant ids can be provided on the command line, via the existing `--client-id` and `--tenant-id` switches, or, when `azure-pipelines` is the `federated-credential-provider`, they can be read from the `AZURESUBSCRIPTION_CLIENT_ID` and `AZURESUBSCRIPTION_TEANT_ID` system environment varaibles. The service connection ID and acceess token are read from the `AZURESUBSCRIPTION_SERVICE_CONNECTION_ID` and `SYSTEM_ACCESSTOKEN` environment variaibles. These system environment variables correspond to what the `AzureCLI@2` sets when passing the `azureSubscription` parameter (after translating the service connection name to a service connection ID, which is handy) allowing something like this to work: ```yaml - task: AzureCLI@2 inputs: azureSubscription: azconnection scriptType: bash scriptLocation: inlineScript inlineScript: | azd auth login --federated-credential-provider "azure-pipelines" azd up ``` Note that while the AzureCLI task is used above, it's only used for setting these environment variables and doing the service connection name to id translation. You could do something like the following instead: ```yaml - bash: | azd auth login --federated-credential-provider "azure-pipelines" azd up env: AZURE_SUBSCRIPTION_CLIENT_ID: "Your Client ID" AZURE_SUBSCRIPTION_TENANT_ID: "Your Tenant ID" AZURE_SUBSCRIPTION_SERVICE_CONNECTION_ID: "Your Service Connection ID" SYSTEM_ACCESSTOKEN: $(System.AccessToken) ``` And things will work as well. This can be useful in cases where you can use the `AzureCLI@2` task directly. We can consider writing our own task as some point as well. Contributes To #4341
- Loading branch information
Showing
6 changed files
with
187 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.