Skip to content

Commit

Permalink
fix(login): use "-p=secret" format for service-principal login
Browse files Browse the repository at this point in the history
prevent login issues, if the first character of the password is '-'
https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az-login
  • Loading branch information
huf1 committed Sep 26, 2024
1 parent f71cdd7 commit 126297a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/recipes/azure_login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (l *Login) interactiveLogin() error {

func (l *Login) servicePrincipalLogin(servicePrincipal string, secret string, tenant string) error {
// First, we log into the Azure CLI
commandText := "az login -u " + servicePrincipal + " -p " + secret + " -t " + tenant + " --service-principal"
// see https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az-login hints for secrets starting with "-"
commandText := "az login -u " + servicePrincipal + " -p=" + secret + " -t " + tenant + " --service-principal"
_, err := l.executor.ExecuteSilent(commandText)

// Then, we also need to set the env variables required for Terraform if working with service principals
Expand All @@ -96,7 +97,7 @@ func (l *Login) servicePrincipalLogin(servicePrincipal string, secret string, te
}

func (l *Login) isUserAlreadyLoggedIn() (bool, error) {
// since we actually rely on errors to test if user is logged in, we will shortly supress the executor panics
// since we actually rely on errors to test if user is logged in, we will shortly suppress the executor panics
previousPanicSetting := error_handling.PanicOnAnyError
error_handling.PanicOnAnyError = false

Expand Down

0 comments on commit 126297a

Please sign in to comment.