Skip to content

Commit

Permalink
Make GSS implement both lib/pq and jackc/pgconn (#4)
Browse files Browse the repository at this point in the history
There was a sneaky little issue because the two libraries use different
spellings for one of the functions.
  • Loading branch information
rafiss authored May 25, 2022
1 parent a00c903 commit 2749fc9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions krb_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
* Keytab support is available only on unix systems
*/

// GSS implements the pq.GSS interface.
// GSS implements the pq.GSS interface and the pgconn.GSS interface.
type GSS struct {
cli *client.Client
ktPath string
Expand Down Expand Up @@ -127,7 +127,7 @@ func (g *GSS) GetInitToken(host string, service string) ([]byte, error) {
return g.GetInitTokenFromSPN(spn)
}

// GetInitTokenFromSpn implements the GSS interface.
// GetInitTokenFromSPN implements the GSS interface.
func (g *GSS) GetInitTokenFromSPN(spn string) ([]byte, error) {
s := spnego.SPNEGOClient(g.cli, spn)

Expand All @@ -144,6 +144,11 @@ func (g *GSS) GetInitTokenFromSPN(spn string) ([]byte, error) {
return b, nil
}

// GetInitTokenFromSpn implements the GSS interface.
func (g *GSS) GetInitTokenFromSpn(spn string) ([]byte, error) {
return g.GetInitTokenFromSPN(spn)
}

// Continue implements the GSS interface.
func (g *GSS) Continue(inToken []byte) (done bool, outToken []byte, err error) {
t := &spnego.SPNEGOToken{}
Expand Down
11 changes: 8 additions & 3 deletions krb_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/alexbrainman/sspi/negotiate"
)

// GSS implements the pq.GSS interface.
// GSS implements the pq.GSS interface and the pgconn.GSS interface.
type GSS struct {
creds *sspi.Credentials
ctx *negotiate.ClientContext
Expand Down Expand Up @@ -49,8 +49,8 @@ func (g *GSS) GetInitToken(host string, service string) ([]byte, error) {
return g.GetInitTokenFromSpn(spn)
}

// GetInitTokenFromSpn implements the GSS interface.
func (g *GSS) GetInitTokenFromSpn(spn string) ([]byte, error) {
// GetInitTokenFromSPN implements the GSS interface.
func (g *GSS) GetInitTokenFromSPN(spn string) ([]byte, error) {
ctx, token, err := negotiate.NewClientContext(g.creds, spn)
if err != nil {
return nil, err
Expand All @@ -61,6 +61,11 @@ func (g *GSS) GetInitTokenFromSpn(spn string) ([]byte, error) {
return token, nil
}

// GetInitTokenFromSpn implements the GSS interface.
func (g *GSS) GetInitTokenFromSpn(spn string) ([]byte, error) {
return g.GetInitTokenFromSPN(spn)
}

// Continue implements the GSS interface.
func (g *GSS) Continue(inToken []byte) (done bool, outToken []byte, err error) {
return g.ctx.Update(inToken)
Expand Down

0 comments on commit 2749fc9

Please sign in to comment.