redis

package
v11.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package redis implements database access proxy that handles authentication, authorization and protocol parsing of connections from Redis clients to Redis standalone or Redis clusters.

After accepting a connection from a Redis client and authorizing it, the proxy dials to the database service agent over a reverse tunnel which dials to the target Redis instance. Unfortunately, Redis 6 (the latest at the moment of writing) only supports password authentication. As Teleport doesn't support password authentication we only authenticate Redis user and leave password authentication to the client.

In case of authorization failure the command is not passed to the server, instead an "access denied" error is sent back to the Redis client in the standard RESP message error format.

Redis Cluster Teleport supports Redis standalone and cluster instances. In the cluster mode MOV and ASK commands are handled internally by go-redis driver, and they are never passed back to a connected client.

Config file In order to pass additional arguments to configure Redis connection Teleport requires using connection URI instead of host + port combination. Example:

  • name: "redis-cluster" protocol: "redis" uri: "rediss://redis.example.com:6379?mode=cluster"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client = redis.Client

Client alias for easier use.

func MakeTestClient

func MakeTestClient(ctx context.Context, config common.TestClientConfig, opts ...ClientOptions) (*Client, error)

MakeTestClient returns Redis client connection according to the provided parameters.

type ClientOptions

type ClientOptions func(*ClientOptionsParams)

ClientOptions allows setting test client options.

func SkipPing

func SkipPing(skip bool) ClientOptions

SkipPing skips Redis server ping right after the connection is established.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOptions

WithTimeout overrides test client's default timeout.

type ClientOptionsParams

type ClientOptionsParams struct {
	// contains filtered or unexported fields
}

ClientOptionsParams is a struct for client configuration options.

type Engine

type Engine struct {
	// EngineConfig is the common database engine configuration.
	common.EngineConfig
	// contains filtered or unexported fields
}

Engine implements common.Engine.

func (*Engine) HandleConnection

func (e *Engine) HandleConnection(ctx context.Context, sessionCtx *common.Session) error

HandleConnection is responsible for connecting to a Redis instance/cluster.

func (*Engine) InitializeConnection

func (e *Engine) InitializeConnection(clientConn net.Conn, sessionCtx *common.Session) error

InitializeConnection initializes the database connection.

func (*Engine) SendError

func (e *Engine) SendError(redisErr error)

SendError sends error message to connected client.

type TestServer

type TestServer struct {
	// contains filtered or unexported fields
}

TestServer is a test Redis server used in functional database access tests. Internally is uses github.com/alicebob/miniredis to simulate Redis server behavior.

func NewTestServer

func NewTestServer(t *testing.T, config common.TestServerConfig, opts ...TestServerOption) (*TestServer, error)

NewTestServer returns a new instance of a test Redis server.

func (*TestServer) Port

func (s *TestServer) Port() string

Port returns a port that test Redis instance is listening on.

type TestServerOption

type TestServerOption func(*TestServer)

TestServerOption allows setting test server options.

func TestServerPassword

func TestServerPassword(password string) TestServerOption

TestServerPassword sets the test Redis server password for default user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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