gatekeeper

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 12 Imported by: 0

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.

For per-caller credential isolation (run registration, token-scoped credentials), use the daemon package, which provides a management API over a Unix socket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSource

ResolveSource creates a CredentialSource from a SourceConfig. Returns an error if the config contains fields not relevant to the selected type.

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"`
}

Config represents a Gate Keeper configuration file.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads and parses a Gate Keeper config from a file path.

func ParseConfig

func ParseConfig(data []byte) (*Config, error)

ParseConfig parses a Gate Keeper config from YAML bytes.

type CredentialConfig

type CredentialConfig struct {
	Host   string       `yaml:"host"`             // Target host (e.g., "api.github.com")
	Header string       `yaml:"header,omitempty"` // Header name (default: "Authorization")
	Prefix string       `yaml:"prefix,omitempty"` // Auth scheme prefix (e.g., "Bearer", "token"); auto-detected if omitted
	Source SourceConfig `yaml:"source"`
	Grant  string       `yaml:"grant,omitempty"` // Optional label for logging
}

CredentialConfig describes a credential to resolve and inject. Host specifies which requests receive the credential. Header names the HTTP header to set (defaults to "Authorization"). Grant is an optional label used for logging.

When the header is "Authorization", the proxy needs a full header value including the auth scheme (e.g., "Bearer token123"). If the source value is a bare token without a scheme prefix, the gatekeeper auto-detects the correct scheme from known token prefixes (GitHub ghp_/gho_/etc.) or defaults to "Bearer". Set Prefix to override the auto-detected scheme.

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)
}

LogConfig configures logging.

type NetworkConfig

type NetworkConfig struct {
	Policy string   `yaml:"policy"`
	Allow  []string `yaml:"allow,omitempty"`
}

NetworkConfig configures network policy.

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
}

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

func New(ctx context.Context, cfg *Config) (*Server, error)

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.

func (*Server) ProxyAddr

func (s *Server) ProxyAddr() string

ProxyAddr returns the proxy listener's actual address (host:port). Returns empty string if the proxy has not started.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the proxy. It blocks until the context is canceled.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down the proxy server.

type SourceConfig

type SourceConfig struct {
	Type   string `yaml:"type"`             // "env", "static", "aws-secretsmanager"
	Var    string `yaml:"var,omitempty"`    // for env source
	Value  string `yaml:"value,omitempty"`  // for static source
	Secret string `yaml:"secret,omitempty"` // for aws-secretsmanager
	Region string `yaml:"region,omitempty"` // for aws-secretsmanager
}

SourceConfig describes where to read a credential value from.

type TLSConfig

type TLSConfig struct {
	CACert string `yaml:"ca_cert"`
	CAKey  string `yaml:"ca_key"`
}

TLSConfig configures the CA certificate used for TLS interception.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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