Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aks): update the aad protocal to try interactive login no matter…
Browse files Browse the repository at this point in the history
… the failure

This change will update the Azure AAD protocol to try an interactive login if the non-interactive login fails for any reason. If the interactive login also fails, then we return an error. We have noticed that some users receive different error messages when attempting to do a non-interactive login, so this change will hopefully cover those other error messages.

Signed-off-by: Casale, Robert <[email protected]>
Gearheads committed Jul 26, 2024
1 parent 97137ed commit f1ce923
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pkg/plugins/identity/azure/aad/aad.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ import (
"fmt"
"os"
"os/exec"
"strings"

"github.com/go-playground/validator/v10"
"go.uber.org/zap"
@@ -140,14 +139,13 @@ func (p *aadIdentityProvider) Authenticate(ctx context.Context, input *provid.Au
err = cmd.Run()

if err != nil {
if strings.Contains(stderr.String(), "Interactive authentication is needed.") {
interactiveLoginRequired = true
cmd = exec.Command("az", "login", "--tenant", cfg.TenantID)
cmd.Stdout = nil
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
cmd.Run()
} else {
interactiveLoginRequired = true
cmd = exec.Command("az", "login", "--tenant", cfg.TenantID)
cmd.Stdout = nil
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("azure cli: %w", err)
}
}

0 comments on commit f1ce923

Please sign in to comment.