Skip to content

Commit

Permalink
Removed breaking API changes to InitSecContext, added APOptions in Cl…
Browse files Browse the repository at this point in the history
…ient struct
  • Loading branch information
p0dalirius committed Dec 13, 2024
1 parent 1cc1eb3 commit f752bf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 2 additions & 5 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ type GSSAPIClient interface {
// reply token is received from the server, passing the reply token
// to InitSecContext via the token parameters.
// See RFC 4752 section 3.1.
InitSecContext(target string, token []byte, APOptions []int) (outputToken []byte, needContinue bool, err error)
InitSecContext(target string, token []byte) (outputToken []byte, needContinue bool, err error)
// NegotiateSaslAuth performs the last step of the Sasl handshake.
// It takes a token, which, when unwrapped, describes the servers supported
// security layers (first octet) and maximum receive buffer (remaining
Expand All @@ -602,8 +602,6 @@ type GSSAPIBindRequest struct {
AuthZID string
// (Optional) Controls to send with the bind request
Controls []Control
// (Optional) APOptions
APOptions []int
}

// GSSAPIBind performs the GSSAPI SASL bind using the provided GSSAPI client.
Expand All @@ -613,7 +611,6 @@ func (l *Conn) GSSAPIBind(client GSSAPIClient, servicePrincipal, authzid string)
&GSSAPIBindRequest{
ServicePrincipalName: servicePrincipal,
AuthZID: authzid,
APOptions: []int{},
},
)
}
Expand All @@ -630,7 +627,7 @@ func (l *Conn) GSSAPIBindRequest(client GSSAPIClient, req *GSSAPIBindRequest) er
for {
if needInit {
// Establish secure context between client and server.
reqToken, needInit, err = client.InitSecContext(req.ServicePrincipalName, recvToken, req.APOptions)
reqToken, needInit, err = client.InitSecContext(req.ServicePrincipalName, recvToken)
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions gssapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type Client struct {

ekey types.EncryptionKey
Subkey types.EncryptionKey

APOptions []int
}

// NewClientWithKeytab creates a new client from a keytab credential.
Expand Down Expand Up @@ -103,7 +105,7 @@ func (client *Client) DeleteSecContext() error {
// InitSecContext initiates the establishment of a security context for
// GSS-API between the client and server.
// See RFC 4752 section 3.1.
func (client *Client) InitSecContext(target string, input []byte, APOptions []int) ([]byte, bool, error) {
func (client *Client) InitSecContext(target string, input []byte) ([]byte, bool, error) {
gssapiFlags := []int{gssapi.ContextFlagInteg, gssapi.ContextFlagConf, gssapi.ContextFlagMutual}

switch input {
Expand All @@ -114,7 +116,7 @@ func (client *Client) InitSecContext(target string, input []byte, APOptions []in
}
client.ekey = ekey

token, err := spnego.NewKRB5TokenAPREQ(client.Client, tkt, ekey, gssapiFlags, APOptions)
token, err := spnego.NewKRB5TokenAPREQ(client.Client, tkt, ekey, gssapiFlags, client.APOptions)
if err != nil {
return nil, false, err
}
Expand Down

0 comments on commit f752bf8

Please sign in to comment.