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 ¶
const ( // URIScheme is a Redis scheme: https://www.iana.org/assignments/uri-schemes/prov/redis // Teleport always uses Redis connection over TLS. URIScheme = "redis" // URISchemeTLS is a Redis scheme that uses TLS for database connection: https://www.iana.org/assignments/uri-schemes/prov/rediss URISchemeTLS = "rediss" )
const DefaultPort = "6379"
DefaultPort is the Redis default port.
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.
type ClientOptionsParams ¶
type ClientOptionsParams struct {
// contains filtered or unexported fields
}
ClientOptionsParams is a struct for client configuration options.
type ConnectionMode ¶
type ConnectionMode string
ConnectionMode defines the mode in which Redis is configured. Currently, supported are single and cluster.
const ( // Standalone mode should be used when connecting to a single Redis instance. Standalone ConnectionMode = "standalone" // Cluster mode should be used when connecting to a Redis Cluster. Cluster ConnectionMode = "cluster" )
type ConnectionOptions ¶
type ConnectionOptions struct {
// contains filtered or unexported fields
}
ConnectionOptions defines Redis connection options.
func ParseRedisAddress ¶
func ParseRedisAddress(addr string) (*ConnectionOptions, error)
ParseRedisAddress parses a Redis connection string and returns the parsed connection options like address and connection mode. If port is skipped default Redis 6379 is used. Correct inputs:
rediss://redis.example.com:6379?mode=cluster redis://redis.example.com:6379 redis.example.com:6379
Incorrect input:
redis.example.com:6379?mode=cluster
func ParseRedisAddressWithDefaultMode ¶
func ParseRedisAddressWithDefaultMode(addr string, defaultMode ConnectionMode) (*ConnectionOptions, error)
ParseRedisAddressWithDefaultMode parses a Redis connection string and uses the provided default mode if mode is not specified in the address.
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 ¶
HandleConnection is responsible for connecting to a Redis instance/cluster.
func (*Engine) InitializeConnection ¶
InitializeConnection initializes the database connection.
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.