fix: boundary authenticate returns an API error code when auth fails (#4342)

This commit is contained in:
Todd committed 2024-01-31 15:11:28 -08:00
1 parent 71c2f8790b
commit d500f24014
1 file changed
+5 -4
@@ -101,26 +101,27 @@ func (c *Command) Run(args []string) int {
c.FlagAuthMethodId = pri
var result int
switch {
case strings.HasPrefix(c.FlagAuthMethodId, globals.PasswordAuthMethodPrefix):
cmd := PasswordCommand{Command: c.Command}
cmd.Opts = append(c.Opts, base.WithSkipScopeIdFlag(true))
cmd.Run([]string{})
result = cmd.Run([]string{})
case strings.HasPrefix(c.FlagAuthMethodId, globals.OidcAuthMethodPrefix):
cmd := OidcCommand{Command: c.Command}
cmd.Opts = append(c.Opts, base.WithSkipScopeIdFlag(true))
cmd.Run([]string{})
result = cmd.Run([]string{})
case strings.HasPrefix(c.FlagAuthMethodId, globals.LdapAuthMethodPrefix):
cmd := LdapCommand{Command: c.Command}
cmd.Opts = append(c.Opts, base.WithSkipScopeIdFlag(true))
cmd.Run([]string{})
result = cmd.Run([]string{})
default:
c.PrintCliError(fmt.Errorf("The primary auth method was of an unsupported type. The given ID was %s; only 'ampw' (password), 'amoidc' (OIDC) and 'amldap' (LDAP) auth method prefixes are supported.", c.FlagAuthMethodId))
return cli.RunResultHelp
}
return 0
return result
}