Skip to content

Commit f1ce923

Browse files
committed
feat(aks): update the aad protocal to try interactive login no matter 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]>
1 parent 97137ed commit f1ce923

File tree

1 file changed

+7
-9
lines changed
  • pkg/plugins/identity/azure/aad

1 file changed

+7
-9
lines changed

pkg/plugins/identity/azure/aad/aad.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"fmt"
2424
"os"
2525
"os/exec"
26-
"strings"
2726

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

142141
if err != nil {
143-
if strings.Contains(stderr.String(), "Interactive authentication is needed.") {
144-
interactiveLoginRequired = true
145-
cmd = exec.Command("az", "login", "--tenant", cfg.TenantID)
146-
cmd.Stdout = nil
147-
cmd.Stdin = os.Stdin
148-
cmd.Stderr = os.Stderr
149-
cmd.Run()
150-
} else {
142+
interactiveLoginRequired = true
143+
cmd = exec.Command("az", "login", "--tenant", cfg.TenantID)
144+
cmd.Stdout = nil
145+
cmd.Stdin = os.Stdin
146+
cmd.Stderr = os.Stderr
147+
err = cmd.Run()
148+
if err != nil {
151149
return nil, fmt.Errorf("azure cli: %w", err)
152150
}
153151
}

0 commit comments

Comments
 (0)