Documentation ¶
Index ¶
- func GetTCPPlugin() tcp.Plugin
- func NewConnector(conRes connector.Resources) tcp.Connector
- func NewMSSQLConnector(dsn string) (types.MSSQLConnector, error)
- func PluginInfo() map[string]string
- func ReadLogin(clientBufRaw io.ReadWriteCloser) (interface{}, error)
- func ReadPreloginWithPacketType(rawTdsBuffer io.ReadWriteCloser, rawPktType uint8) (map[uint8][]byte, error)
- func WritePreloginWithPacketType(rawTdsBuffer io.ReadWriteCloser, fields map[uint8][]byte, rawPktType uint8) error
- type ConnectionDetails
- type SingleUseConnector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTCPPlugin ¶
GetTCPPlugin is required as part of the Secretless plugin spec for TCP connector plugins. It returns the TCP plugin.
func NewConnector ¶
NewConnector returns a tcp.Connector which returns an authenticated connection to a target service for each incoming client connection. It is a required method on the tcp.Plugin interface. The single argument passed in is of type connector.Resources. It contains connector-specific config and a logger.
func NewMSSQLConnector ¶ added in v1.4.2
func NewMSSQLConnector(dsn string) (types.MSSQLConnector, error)
NewMSSQLConnector is the production implementation of MSSQLConnectorCtor, used for creating mssql.Connector instances. We need to wrap the raw constructor provided by mssql (ie, mssql.NewConnector) in this function so that it returns an interface, which enables us to mock it in unit tests.
func PluginInfo ¶
PluginInfo is required as part of the Secretless plugin spec. It provides important metadata about the plugin.
func ReadLogin ¶ added in v1.4.2
func ReadLogin(clientBufRaw io.ReadWriteCloser) (interface{}, error)
ReadLogin is the production version of our readLogin dependency, which delegates to the actual 3rd party driver.
func ReadPreloginWithPacketType ¶ added in v1.4.2
func ReadPreloginWithPacketType( rawTdsBuffer io.ReadWriteCloser, rawPktType uint8, ) (map[uint8][]byte, error)
ReadPreloginWithPacketType is the production version of our readPrelogin dependency, which delegates to the actual 3rd party driver.
func WritePreloginWithPacketType ¶ added in v1.4.2
func WritePreloginWithPacketType( rawTdsBuffer io.ReadWriteCloser, fields map[uint8][]byte, rawPktType uint8, ) error
WritePreloginWithPacketType is the production version of our writePrelogin dependency, which delegates to the actual 3rd party driver.
Types ¶
type ConnectionDetails ¶
ConnectionDetails stores the connection info to the real backend database. These values are pulled from the SingleUseConnector credentials config
func NewConnectionDetails ¶
func NewConnectionDetails(credentials map[string][]byte) (*ConnectionDetails, error)
NewConnectionDetails is a constructor of ConnectionDetails structure from a map of credentials.
func (*ConnectionDetails) Address ¶
func (cd *ConnectionDetails) Address() string
Address returns a string representing the network location (host and port) of a MSSQL server. This is the string you would would typically use to connect to the database -- eg, in cmd line tools.
type SingleUseConnector ¶
type SingleUseConnector struct {
// contains filtered or unexported fields
}
SingleUseConnector is used to create an authenticated connection to an MSSQL target
func NewSingleUseConnector ¶ added in v1.4.2
func NewSingleUseConnector(logger log.Logger) *SingleUseConnector
NewSingleUseConnector creates a new production SingleUseConnector
func NewSingleUseConnectorWithOptions ¶ added in v1.4.2
func NewSingleUseConnectorWithOptions( logger log.Logger, newMSSQLConnector types.MSSQLConnectorCtor, readPrelogin types.ReadPreloginFunc, writePrelogin types.WritePreloginFunc, readLogin types.ReadLoginFunc, newTdsBuffer types.TdsBufferCtor, ) *SingleUseConnector
NewSingleUseConnectorWithOptions creates a new SingleUseConnector, and allows you to specify the newMSSQLConnector explicitly. Intended to be used in unit tests only.
func (*SingleUseConnector) Connect ¶
func (connector *SingleUseConnector) Connect( clientConn net.Conn, credentialValuesByID connector.CredentialValuesByID, ) (net.Conn, error)
Connect implements the tcp.Connector func signature
It is the main method of the SingleUseConnector. It:
- Constructs connection details from the provided credentials map.
- Reads the client PreLogin request
- Adds channels to the context that can intercept data from the driver
- Initiates authentication and connection to MsSQL through the third-party driver
- Intercepts PreLogin response from the driver
- Customizes the PreLogin response to meet Secretless standards and sends it to the user
Connect requires "host", "port", "username" and "password" credentials.
func (*SingleUseConnector) CreateAuthenticationOKMessage ¶
func (connector *SingleUseConnector) CreateAuthenticationOKMessage() []byte
CreateAuthenticationOKMessage creates an MSSQL message which indicates successful authentication.
func (*SingleUseConnector) CreateGenericErrorMessage ¶
func (connector *SingleUseConnector) CreateGenericErrorMessage() []byte
CreateGenericErrorMessage creates an MSSQL error message