Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gssapi plugin auth #1233

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -76,6 +76,7 @@ Olivier Mengué <dolmen at cpan.org>
oscarzhao <oscarzhaosl at gmail.com>
Paul Bonser <misterpib at gmail.com>
Peter Schultz <peter.schultz at classmarkets.com>
Polina Osadcha <posadcha-ua at singlestore.com>
Rebecca Chin <rchin at pivotal.io>
Reed Allman <rdallman10 at gmail.com>
Richard Wilkes <wilkes at me.com>
Expand Down
32 changes: 32 additions & 0 deletions auth.go
Expand Up @@ -17,6 +17,8 @@ import (
"encoding/pem"
"fmt"
"sync"

"github.com/openshift/gssapi"
)

// server pub keys registry
Expand Down Expand Up @@ -289,6 +291,36 @@ func (mc *mysqlConn) auth(authData []byte, plugin string) ([]byte, error) {
enc, err := encryptPassword(mc.cfg.Passwd, authData, pubKey)
return enc, err

case "auth_gssapi_client":
dl, err := gssapi.Load(nil)
if err != nil {
return nil, err
}

buf_name, err := dl.MakeBufferBytes(authData)
if err != nil {
return nil, err
}
name, err := buf_name.Name(dl.GSS_C_NT_USER_NAME)
input_buf, _ := dl.MakeBuffer(0)
if err != nil {
return nil, err
}
_, _, token, _, _, err := dl.InitSecContext(
dl.GSS_C_NO_CREDENTIAL,
nil,
name,
dl.GSS_C_NO_OID,
0,
0,
dl.GSS_C_NO_CHANNEL_BINDINGS,
input_buf)
if token == nil {
return nil, err
}

return token.Bytes(), err

default:
errLog.Print("unknown auth plugin:", plugin)
return nil, ErrUnknownPlugin
Expand Down
2 changes: 2 additions & 0 deletions go.mod
@@ -1,3 +1,5 @@
module github.com/go-sql-driver/mysql

go 1.13

require github.com/openshift/gssapi v0.0.0-20161010215902-5fb4217df13b