-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthentication.go
33 lines (28 loc) · 1.05 KB
/
authentication.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package msg
import (
"github.com/renthraysk/mysqlx/proto"
"github.com/renthraysk/mysqlx/protobuf/mysqlx"
)
// NewAuthenticateStart marshals a AuthenticateStart protobuf message
func NewAuthenticateStart(buf []byte, mechName string, authData []byte) MsgBytes {
const (
tagAuthenticateStartMechName = 1
tagAuthenticateStartAuthData = 2
tagAuthenticateStartInitialResponse = 3
)
b := append(buf[len(buf):], 0, 0, 0, 0, byte(mysqlx.ClientMessages_SESS_AUTHENTICATE_START))
b = proto.AppendWireString(b, tagAuthenticateStartMechName, mechName)
if len(authData) > 0 {
b = proto.AppendWireBytes(b, tagAuthenticateStartAuthData, authData)
}
return MsgBytes(b)
}
// NewAuthenticateContinue marshals AuthenticateContinue protobuf message
func NewAuthenticateContinue(buf []byte, authData []byte) MsgBytes {
const (
tagAuthenticateContinueAuthData = 1
)
b := append(buf[len(buf):], 0, 0, 0, 0, byte(mysqlx.ClientMessages_SESS_AUTHENTICATE_CONTINUE))
b = proto.AppendWireBytes(b, tagAuthenticateContinueAuthData, authData)
return MsgBytes(b)
}