Skip to content

Commit

Permalink
Update Kerberos library to latest major
Browse files Browse the repository at this point in the history
New import path: github.com/jcmturner/gokrb5/v8
  • Loading branch information
kvch authored and bai committed Jan 22, 2021
1 parent 29d67db commit acced82
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 25 deletions.
2 changes: 1 addition & 1 deletion broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

"github.com/jcmturner/gokrb5/v8/krberror"
"github.com/rcrowley/go-metrics"
"gopkg.in/jcmturner/gokrb5.v7/krberror"
)

func ExampleBroker() {
Expand Down
16 changes: 8 additions & 8 deletions gssapi_kerberos.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package sarama

import (
"encoding/asn1"
"encoding/binary"
"fmt"
"io"
"strings"
"time"

"github.com/jcmturner/gofork/encoding/asn1"
"gopkg.in/jcmturner/gokrb5.v7/asn1tools"
"gopkg.in/jcmturner/gokrb5.v7/gssapi"
"gopkg.in/jcmturner/gokrb5.v7/iana/chksumtype"
"gopkg.in/jcmturner/gokrb5.v7/iana/keyusage"
"gopkg.in/jcmturner/gokrb5.v7/messages"
"gopkg.in/jcmturner/gokrb5.v7/types"
"github.com/jcmturner/gokrb5/v8/asn1tools"
"github.com/jcmturner/gokrb5/v8/gssapi"
"github.com/jcmturner/gokrb5/v8/iana/chksumtype"
"github.com/jcmturner/gokrb5/v8/iana/keyusage"
"github.com/jcmturner/gokrb5/v8/messages"
"github.com/jcmturner/gokrb5/v8/types"
)

const (
Expand Down Expand Up @@ -154,7 +154,7 @@ func (krbAuth *GSSAPIKerberosAuth) createKrb5Token(
*
*/
func (krbAuth *GSSAPIKerberosAuth) appendGSSAPIHeader(payload []byte) ([]byte, error) {
oidBytes, err := asn1.Marshal(gssapi.OID(gssapi.OIDKRB5))
oidBytes, err := asn1.Marshal(gssapi.OIDKRB5.OID())
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions kerberos_client.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package sarama

import (
krb5client "gopkg.in/jcmturner/gokrb5.v7/client"
krb5config "gopkg.in/jcmturner/gokrb5.v7/config"
"gopkg.in/jcmturner/gokrb5.v7/keytab"
"gopkg.in/jcmturner/gokrb5.v7/types"
krb5client "github.com/jcmturner/gokrb5/v8/client"
krb5config "github.com/jcmturner/gokrb5/v8/config"
"github.com/jcmturner/gokrb5/v8/keytab"
"github.com/jcmturner/gokrb5/v8/types"
)

type KerberosGoKrb5Client struct {
Expand Down Expand Up @@ -37,9 +37,9 @@ func createClient(config *GSSAPIConfig, cfg *krb5config.Config) (KerberosClient,
if err != nil {
return nil, err
}
client = krb5client.NewClientWithKeytab(config.Username, config.Realm, kt, cfg, krb5client.DisablePAFXFAST(config.DisablePAFXFAST))
client = krb5client.NewWithKeytab(config.Username, config.Realm, kt, cfg, krb5client.DisablePAFXFAST(config.DisablePAFXFAST))
} else {
client = krb5client.NewClientWithPassword(config.Username,
client = krb5client.NewWithPassword(config.Username,
config.Realm, config.Password, cfg, krb5client.DisablePAFXFAST(config.DisablePAFXFAST))
}
return &KerberosGoKrb5Client{*client}, nil
Expand Down
52 changes: 47 additions & 5 deletions kerberos_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"errors"
"testing"

krbcfg "gopkg.in/jcmturner/gokrb5.v7/config"
"gopkg.in/jcmturner/gokrb5.v7/test/testdata"
krbcfg "github.com/jcmturner/gokrb5/v8/config"
)

/*
Expand All @@ -15,6 +14,49 @@ import (
*
*/

const (
krb5cfg = `[libdefaults]
default_realm = TEST.GOKRB5
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
forwardable = yes
default_tkt_enctypes = aes256-cts-hmac-sha1-96
default_tgs_enctypes = aes256-cts-hmac-sha1-96
noaddresses = false
[realms]
TEST.GOKRB5 = {
kdc = 127.0.0.1:88
admin_server = 127.0.0.1:749
default_domain = test.gokrb5
}
RESDOM.GOKRB5 = {
kdc = 10.80.88.88:188
admin_server = 127.0.0.1:749
default_domain = resdom.gokrb5
}
USER.GOKRB5 = {
kdc = 192.168.88.100:88
admin_server = 192.168.88.100:464
default_domain = user.gokrb5
}
RES.GOKRB5 = {
kdc = 192.168.88.101:88
admin_server = 192.168.88.101:464
default_domain = res.gokrb5
}
[domain_realm]
.test.gokrb5 = TEST.GOKRB5
test.gokrb5 = TEST.GOKRB5
.resdom.gokrb5 = RESDOM.GOKRB5
resdom.gokrb5 = RESDOM.GOKRB5
.user.gokrb5 = USER.GOKRB5
user.gokrb5 = USER.GOKRB5
.res.gokrb5 = RES.GOKRB5
res.gokrb5 = RES.GOKRB5
`
)

func TestFaildToCreateKerberosConfig(t *testing.T) {
expectedErr := errors.New("configuration file could not be opened: krb5.conf open krb5.conf: no such file or directory")
clientConfig := NewTestConfig()
Expand All @@ -34,7 +76,7 @@ func TestFaildToCreateKerberosConfig(t *testing.T) {
}

func TestCreateWithPassword(t *testing.T) {
kerberosConfig, err := krbcfg.NewConfigFromString(testdata.TEST_KRB5CONF)
kerberosConfig, err := krbcfg.NewFromString(krb5cfg)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -64,7 +106,7 @@ func TestCreateWithPassword(t *testing.T) {
}

func TestCreateWithKeyTab(t *testing.T) {
kerberosConfig, err := krbcfg.NewConfigFromString(testdata.TEST_KRB5CONF)
kerberosConfig, err := krbcfg.NewFromString(krb5cfg)
if err != nil {
t.Fatal(err)
}
Expand All @@ -86,7 +128,7 @@ func TestCreateWithKeyTab(t *testing.T) {
}

func TestCreateWithDisablePAFXFAST(t *testing.T) {
kerberosConfig, err := krbcfg.NewConfigFromString(testdata.TEST_KRB5CONF)
kerberosConfig, err := krbcfg.NewFromString(krb5cfg)
if err != nil {
t.Fatal(err)
}
Expand Down
10 changes: 5 additions & 5 deletions mockkerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"encoding/binary"
"encoding/hex"

"gopkg.in/jcmturner/gokrb5.v7/credentials"
"gopkg.in/jcmturner/gokrb5.v7/gssapi"
"gopkg.in/jcmturner/gokrb5.v7/iana/keyusage"
"gopkg.in/jcmturner/gokrb5.v7/messages"
"gopkg.in/jcmturner/gokrb5.v7/types"
"github.com/jcmturner/gokrb5/v8/credentials"
"github.com/jcmturner/gokrb5/v8/gssapi"
"github.com/jcmturner/gokrb5/v8/iana/keyusage"
"github.com/jcmturner/gokrb5/v8/messages"
"github.com/jcmturner/gokrb5/v8/types"
)

type KafkaGSSAPIHandler struct {
Expand Down

0 comments on commit acced82

Please sign in to comment.