Skip to content

Commit 126297a

Browse files
committed
fix(login): use "-p=secret" format for service-principal login
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
1 parent f71cdd7 commit 126297a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/recipes/azure_login/login.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func (l *Login) interactiveLogin() error {
7979

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

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

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

0 commit comments

Comments
 (0)