mssql

package
v1.7.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTCPPlugin

func GetTCPPlugin() tcp.Plugin

GetTCPPlugin is required as part of the Secretless plugin spec for TCP connector plugins. It returns the TCP plugin.

func NewConnector

func NewConnector(conRes connector.Resources) tcp.Connector

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

func PluginInfo() map[string]string

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:

  1. Reads the client PreLogin request
  2. Constructs connection details from the provided credentials map
  3. Adds a ConnectInterceptor to the context to exchange data with the driver via channels
  4. Initiates authentication and connection to MSSQL through the third-party driver
  5. Injects client's PreLogin request to the driver, which the driver incorporates into its PreLogin request to server
  6. Intercepts PreLogin response or error from the driver
  7. Customizes the PreLogin response to meet Secretless standards and sends it to client
  8. Intercepts Login response or error from the driver, and simultaneously extracts net.Conn to server from the driver
  9. Sends Login response or error to client

Connect requires "host", "port", "username" and "password" credentials.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL