Documentation ¶
Index ¶
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.
Types ¶
type ConnectionDetails ¶
type ConnectionDetails struct { Host string Port uint Username string Password string SSLParams map[string]string }
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
NewConnectionDetails is a constructor of ConnectionDetails structure from a map of credentials.
func (*ConnectionDetails) URL ¶ added in v1.6.0
func (cd *ConnectionDetails) URL() string
URL returns a string URL from connection details
type SingleUseConnector ¶
type SingleUseConnector struct { types.ConnectorOptions // 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. This uses the production version of the dependencies, which delegate to the actual 3rd party driver.
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:
- Reads the client PreLogin request
- Constructs connection details from the provided credentials map
- Adds a ConnectInterceptor to the context to exchange data with the driver via channels
- Initiates authentication and connection to MSSQL through the third-party driver
- Injects client's PreLogin request to the driver, which the driver incorporates into its PreLogin request to server
- Intercepts PreLogin response or error from the driver
- Customizes the PreLogin response to meet Secretless standards and sends it to client
- Intercepts Login response or error from the driver, and simultaneously extracts net.Conn to server from the driver
- Sends Login response or error to client
Connect requires "host", "port", "username" and "password" credentials.