proxy

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GrabUnusedPort

func GrabUnusedPort() (int, error)

func InitiateSessionConnection

func InitiateSessionConnection(cfg *config.Context, input InitiateSessionConnectionInput) (net.Conn, *yamux.Session, error)

InitiateSessionConnection starts a new tcp connection to through the SSM port forward and completes a handshake with the proxy server the result is a yamux session which is used to multiplex client connections

func ListenAndProxy

func ListenAndProxy(ctx context.Context, yamuxStreamConnection *yamux.Session, clientConnectionPort int, requestURL string) error

ListenAndProxy will listen for new client connections and start a stream over the established proxy server session. if the proxy server terminates the session, like when a grant expires, this listener will detect it and terminate the CLI commmand with an error explaining what happened

func Ports

func Ports(isLocalMode bool) (serverPort, localPort int, err error)

Returns the proxy port to connect to and a local port to send client connections to in production, an SSM portforward process is running which is used to connect to the proxy server and over the top of this connection, a handshake process takes place and connection multiplexing is used to handle multiple database clients

func PromptEntitlements added in v0.36.1

func PromptEntitlements(entitlements []*accessv1alpha1.Entitlement, targetHeader string, roleHeader string, promptMessage string) (*accessv1alpha1.Entitlement, error)

func WaitForSSMConnectionToProxyServer

func WaitForSSMConnectionToProxyServer(ctx context.Context, opts WaitForSSMConnectionToProxyServerOpts) error

WaitForSSMConnectionToProxyServer starts a session with SSM and waits for the connection to be ready

Types

type AWSConfig

type AWSConfig struct {
	SSOAccountID     string
	SSORoleName      string
	SSORegion        string
	SSOStartURL      string
	Region           string
	SSMSessionTarget string
	NoCache          bool
}

type ConnectionOpts

type ConnectionOpts struct {
	ServerPort int
	LocalPort  int
}

type DebugWriter

type DebugWriter struct{}

DebugWriter is an io.Writer that writes messages using clio.Debug.

func (DebugWriter) Write

func (dw DebugWriter) Write(p []byte) (n int, err error)

Write implements the io.Writer interface for DebugWriter.

type DisplayOpts

type DisplayOpts struct {
	//the e.g `aws rds proxy` which is used to fill in a help prompt
	Command string
	// like `EKS Proxy` or `RDS proxy`
	SessionType string
}

type EnsureAccessInput

type EnsureAccessInput[T any] struct {
	Target               string
	Role                 string
	Duration             time.Duration
	Reason               string
	Confirm              bool
	Wait                 bool
	PromptForEntitlement func(ctx context.Context, cfg *config.Context) (*accessv1alpha1.Entitlement, error)
	GetGrantOutput       func(msg *accessv1alpha1.GetGrantOutputResponse) (T, error)
}

type EnsureAccessOutput

type EnsureAccessOutput[T any] struct {
	GrantOutput T
	Grant       *accessv1alpha1.Grant
}

func EnsureAccess

func EnsureAccess[T any](ctx context.Context, cfg *config.Context, input EnsureAccessInput[T]) (*EnsureAccessOutput[T], error)

ensureAccess checks for an existing grant or creates a new one if it does not exist

type InitiateSessionConnectionInput

type InitiateSessionConnectionInput struct {
	GrantID    string
	RequestURL string
	LocalPort  int
}

type NotifyOnSubstringMatchWriter

type NotifyOnSubstringMatchWriter struct {
	Phrase   string
	Callback func()
}

func (*NotifyOnSubstringMatchWriter) Write

func (nw *NotifyOnSubstringMatchWriter) Write(p []byte) (n int, err error)

type SSMDebugLogger

type SSMDebugLogger struct {
	// Writers to write logging output to
	Writers []io.Writer
}

func (*SSMDebugLogger) Close

func (l *SSMDebugLogger) Close()

func (*SSMDebugLogger) Critical

func (l *SSMDebugLogger) Critical(v ...interface{}) error

func (*SSMDebugLogger) Criticalf

func (l *SSMDebugLogger) Criticalf(format string, params ...interface{}) error

func (*SSMDebugLogger) Debug

func (l *SSMDebugLogger) Debug(v ...interface{})

func (*SSMDebugLogger) Debugf

func (l *SSMDebugLogger) Debugf(format string, params ...interface{})

func (*SSMDebugLogger) Error

func (l *SSMDebugLogger) Error(v ...interface{}) error

func (*SSMDebugLogger) Errorf

func (l *SSMDebugLogger) Errorf(format string, params ...interface{}) error

func (*SSMDebugLogger) Flush

func (l *SSMDebugLogger) Flush()

func (*SSMDebugLogger) Info

func (l *SSMDebugLogger) Info(v ...interface{})

func (*SSMDebugLogger) Infof

func (l *SSMDebugLogger) Infof(format string, params ...interface{})

func (*SSMDebugLogger) Trace

func (l *SSMDebugLogger) Trace(v ...interface{})

func (*SSMDebugLogger) Tracef

func (l *SSMDebugLogger) Tracef(format string, params ...interface{})

func (*SSMDebugLogger) Warn

func (l *SSMDebugLogger) Warn(v ...interface{}) error

func (*SSMDebugLogger) Warnf

func (l *SSMDebugLogger) Warnf(format string, params ...interface{}) error

func (*SSMDebugLogger) WithContext

func (l *SSMDebugLogger) WithContext(context ...string) (contextLogger log.T)

type WaitForSSMConnectionToProxyServerOpts

type WaitForSSMConnectionToProxyServerOpts struct {
	AWSConfig      AWSConfig
	DisplayOpts    DisplayOpts
	ConnectionOpts ConnectionOpts
	GrantID        string
	RequestID      string
}

Jump to

Keyboard shortcuts

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