Documentation
¶
Overview ¶
Package gatekeeper provides a standalone credential-injecting TLS proxy.
Credentials are pre-configured in gatekeeper.yaml and injected for all proxied requests matching the host. Access control is via network policy (who can reach the proxy) and an optional static auth token.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Proxy ProxyConfig `yaml:"proxy"`
TLS TLSConfig `yaml:"tls"`
Credentials []CredentialConfig `yaml:"credentials"`
Network NetworkConfig `yaml:"network"`
Log LogConfig `yaml:"log"`
Postgres *PostgresConfig `yaml:"postgres,omitempty"`
}
Config represents a Gate Keeper configuration file.
func LoadConfig ¶
LoadConfig reads and parses a Gate Keeper config from a file path.
func ParseConfig ¶
ParseConfig parses a Gate Keeper config from YAML bytes.
type CredentialConfig ¶
type CredentialConfig = proxy.Credential
CredentialConfig is the YAML configuration form of proxy.Credential.
type LogConfig ¶
type LogConfig struct {
Level string `yaml:"level"` // Log level (e.g., "debug", "info", "warn", "error")
Format string `yaml:"format"` // Output format ("json" or "text")
Output string `yaml:"output"` // Destination ("stderr", "stdout", or a file path; default: stderr)
CaptureRequestHeaders []string `yaml:"capture_request_headers,omitempty"`
CaptureResponseHeaders []string `yaml:"capture_response_headers,omitempty"`
}
LogConfig configures logging.
type MatchConfig ¶ added in v0.32.0
type MatchConfig = proxy.RequestMatch
MatchConfig is the request predicate type used by credentials.
type NetworkConfig ¶
NetworkConfig configures network policy.
type Options ¶ added in v0.27.0
type Options struct {
// Version is included in the startup log line.
Version string
// Logger receives the server's own log lines. Nil means slog.Default().
// The log.level, log.format, and log.output config keys apply only to
// the gatekeeper binary, which builds this logger from them.
Logger *slog.Logger
}
Options are the process-level inputs to New that are not part of the YAML configuration.
type PostgresConfig ¶ added in v0.12.0
type PostgresConfig struct {
Port int `yaml:"port"` // listener port (e.g. 5432)
Host string `yaml:"host,omitempty"` // bind address (default: same as proxy host)
// ProxyProtocol enables PROXY protocol v1/v2 parsing on the Postgres
// data-plane listener, mirroring proxy.proxy_protocol: when true, each
// inbound connection is checked for a leading PROXY protocol header (as
// prepended by a TCP-terminating load balancer in front of the Postgres
// port) and, if present, the advertised source address replaces the raw
// TCP peer address as the connection's client address for logging.
// Connections that do not open with a PROXY header fall back to the raw
// TCP peer address (fail-open), so load balancer health checks and
// direct probes of the port keep working. Default false.
//
// Because headers are honored from any peer, a client that can reach
// this listener directly (bypassing the load balancer) can forge the
// logged client_ip by prepending its own PROXY header. Only enable this
// when the port is reachable solely through the load balancer, and never
// use client_ip for security decisions.
ProxyProtocol bool `yaml:"proxy_protocol,omitempty"`
}
PostgresConfig configures the Postgres data-plane listener. When present, gatekeeper starts a Postgres-protocol listener that authenticates clients with their run token and injects resolved database credentials upstream.
type PostgresCredentialConfig ¶ added in v0.12.0
type PostgresCredentialConfig = proxy.PostgresCredentialConfig
type ProxyConfig ¶
type ProxyConfig struct {
Port int `yaml:"port"`
Host string `yaml:"host"`
AuthToken string `yaml:"auth_token,omitempty"` // Optional token clients must provide via Proxy-Authorization
// AuthTokenEnv names an environment variable holding the proxy auth
// token, read once at startup. Mutually exclusive with AuthToken: set
// one or the other, not both. The named variable must be set and
// non-empty at startup.
AuthTokenEnv string `yaml:"auth_token_env,omitempty"`
// ProxyProtocol enables PROXY protocol v1/v2 parsing on the HTTP/CONNECT
// proxy listener. When true, each inbound connection is checked for a
// leading PROXY protocol header (as prepended by a TCP load balancer,
// e.g. GCP's global TCP Proxy LB) and, if present, the advertised source
// address replaces the raw TCP peer address as the connection's client
// address for logging (the client_ip request-log attribute). Connections
// that do not open with a PROXY header fall back to the raw TCP peer
// address (fail-open), so load balancer health checks and direct probes
// of the port keep working. Default false.
//
// Because headers are honored from any peer, a client that can reach the
// listener directly (bypassing the load balancer) can forge the logged
// client_ip by prepending its own PROXY header. Only enable this when
// the port is reachable solely through the load balancer, and never use
// client_ip for security decisions.
ProxyProtocol bool `yaml:"proxy_protocol,omitempty"`
}
ProxyConfig configures the proxy listener.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the Gate Keeper server. It manages a TLS-intercepting proxy with statically configured credentials.
func New ¶
New creates a new Gate Keeper server from the given configuration. The context is used for credential fetching (e.g., AWS Secrets Manager) and can be used to cancel startup if the process receives a signal. New never changes process-global state.
func (*Server) PostgresAddr ¶ added in v0.12.0
PostgresAddr returns the Postgres data-plane listener's actual address (host:port). Returns empty string if no Postgres listener is configured or it has not started.
func (*Server) ProxyAddr ¶
ProxyAddr returns the proxy listener's actual address (host:port). Returns empty string if the proxy has not started.
type SourceConfig ¶
type SourceConfig = proxy.SourceConfig
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gatekeeper
command
|
|
|
Package proxy provides a TLS-intercepting HTTP proxy for credential injection.
|
Package proxy provides a TLS-intercepting HTTP proxy for credential injection. |