Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Apr 28, 2020
1 parent 947e4c2 commit bb46dfc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions libbeat/common/transport/kerberos/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package kerberos
import (
"fmt"
"net/http"
"net/url"

krbclient "gopkg.in/jcmturner/gokrb5.v7/client"
krbconfig "gopkg.in/jcmturner/gokrb5.v7/config"
Expand All @@ -40,25 +39,20 @@ func NewClient(config *Config, httpClient *http.Client, esurl string) (*Client,
}

switch config.AuthType {
case AUTH_KEYTAB:
case authKeytab:
kTab, err := keytab.Load(config.KeyTabPath)
if err != nil {
return nil, fmt.Errorf("cannot load keytab file %s: %+v", config.KeyTabPath, err)
}
krbClient = krbclient.NewClientWithKeytab(config.Username, config.Realm, kTab, krbConf)
case AUTH_PASSWORD:
case authPassword:
krbClient = krbclient.NewClientWithPassword(config.Username, config.Realm, config.Password, krbConf)
default:
return nil, InvalidAuthType
}

parsedURL, err := url.Parse(esurl)
if err != nil {
return nil, fmt.Errorf("cannot parse elasticsearch URL %s: %v", esurl, err)
}
spn := fmt.Sprintf("HTTP/%s@%s", parsedURL.Hostname(), config.Realm)
return &Client{
spClient: spnego.NewClient(krbClient, httpClient, spn),
spClient: spnego.NewClient(krbClient, httpClient, ""),
}, nil
}

Expand Down

0 comments on commit bb46dfc

Please sign in to comment.