Skip to content

Commit

Permalink
Merge pull request #16 from Icinga/feature/default-auth
Browse files Browse the repository at this point in the history
Change default auth type to NTLM
  • Loading branch information
Philipp D authored Sep 21, 2020
2 parents 758f400 + 0418ff0 commit 4580086
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
const (
Port = 5985
TlsPort = 5986
AuthDefault = AuthBasic
AuthDefault = AuthNTLM
AuthBasic = "basic"
AuthNTLM = "ntlm"
AuthSSH = "ssh"
Expand Down Expand Up @@ -66,7 +66,7 @@ func BuildConfigFlags(fs *pflag.FlagSet) (config *Config) {
fs.StringVar(&config.IcingaCommand, "icingacmd", "",
"Executes commands of Icinga PowerShell Framework (e.g. Invoke-IcingaCheckCPU)")

fs.StringVar(&config.AuthType, "auth", AuthDefault, "Authentication mechanism - NTLM | SSH")
fs.StringVar(&config.AuthType, "auth", AuthDefault, "Authentication mechanism - Basic, NTLM, TLS, SSH")

// AuthSSH
fs.StringVar(&config.SSHHost, "sshhost", "", "SSH Host (mandatory if --auth=SSH)")
Expand Down Expand Up @@ -136,6 +136,10 @@ func (c *Config) Validate() (err error) {
}

// AuthType
if c.AuthType == "" {
c.AuthType = AuthDefault
}

auth := strings.ToLower(c.AuthType)
switch auth {
case AuthBasic, AuthNTLM:
Expand All @@ -147,8 +151,6 @@ func (c *Config) Validate() (err error) {
if c.SSHHost == "" || c.SSHUser == "" || c.SSHPassword == "" {
return fmt.Errorf("please specify host, user and port for auth type: %s", c.AuthType)
}
case "":
auth = AuthDefault
default:
return fmt.Errorf("invalid auth type specified: %s", c.AuthType)
}
Expand Down
2 changes: 1 addition & 1 deletion check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestConfig_Validate(t *testing.T) {
assert.NoError(t, c.Validate())
assert.Equal(t, c.Port, TlsPort)
assert.False(t, c.NoTls)
assert.Equal(t, c.AuthType, AuthBasic)
assert.Equal(t, c.AuthType, AuthDefault)
assert.True(t, c.validated)
}

Expand Down

0 comments on commit 4580086

Please sign in to comment.