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
- func ResolveCredentialSource(cred CredentialConfig) (credentialsource.CredentialSource, proxy.CredentialResolver, error)
- func ResolveSource(cfg SourceConfig) (credentialsource.CredentialSource, error)
- type Config
- type CredentialConfig
- type LogConfig
- type NetworkConfig
- type PostgresConfig
- type PostgresCredentialConfig
- type ProxyConfig
- type Server
- type SourceConfig
- type TLSConfig
Constants ¶
const OTelDiagnosticKey = "otel_diagnostic"
OTelDiagnosticKey marks a log record as gatekeeper's own diagnostic about the OTel pipeline itself — currently, the OTel SDK/export error records cmd/gatekeeper's logOTelError logs at DEBUG. configureLogging's otelslog bridge handler excludes any record carrying this attribute (see newOTelDiagnosticFilter): without the exclusion, a failed OTel log export produces a DEBUG diagnostic that is itself fanned out to the same OTel log-export pipeline that just failed, so it gets queued, fails on the next export attempt, produces another diagnostic, and so on indefinitely while a collector is unreachable. The console/file handler still receives every record regardless of this marker.
Variables ¶
This section is empty.
Functions ¶
func ResolveCredentialSource ¶ added in v0.5.0
func ResolveCredentialSource(cred CredentialConfig) (credentialsource.CredentialSource, proxy.CredentialResolver, error)
ResolveCredentialSource creates either a static CredentialSource or a dynamic CredentialResolver from a credential config. For static sources (env, static, process, aws-secretsmanager, gcp-secretmanager, gcp-service-account, github-app), the first return is non-nil. For dynamic sources (token-exchange), the second return is non-nil.
func ResolveSource ¶
func ResolveSource(cfg SourceConfig) (credentialsource.CredentialSource, error)
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"`
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 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
Format string `yaml:"format,omitempty"` // Auth format: "" (default scheme prefix) or "basic" (HTTP Basic)
Source SourceConfig `yaml:"source"`
Grant string `yaml:"grant,omitempty"` // Optional label for logging
Postgres *PostgresCredentialConfig `yaml:"postgres,omitempty"`
}
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.
For hosts that require HTTP Basic authentication (e.g., github.com git smart HTTP), set Format to "basic" and Prefix to the Basic auth username. The credential value becomes the password: Authorization: Basic base64(prefix:value).
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)
CaptureHeaders []string `yaml:"capture_headers,omitempty"` // Request headers to log and strip before forwarding
}
LogConfig configures logging.
type NetworkConfig ¶
NetworkConfig configures network policy.
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 struct {
Resolver string `yaml:"resolver"`
Project string `yaml:"project,omitempty"` // optional Neon project ID; required for project-scoped API keys
}
PostgresCredentialConfig marks a credential as a Postgres credential and selects how the upstream password is resolved. Resolver is "neon" (the Source supplies the Neon API key, passwords are minted per branch) or "static" (the Source supplies the password directly).
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
// 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. The version string is included in the startup log line; pass "" if unknown.
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 struct {
Type string `yaml:"type"` // "env", "static", "process", "aws-secretsmanager", "gcp-secretmanager", "gcp-service-account", "github-app", "token-exchange"
Var string `yaml:"var,omitempty"` // for env source
Value string `yaml:"value,omitempty"` // for static source
Command string `yaml:"command,omitempty"` // for process source: host command run with `sh -c`
TTL string `yaml:"ttl,omitempty"` // for process source: refresh interval when output has no expiry (Go duration, default 5m)
Secret string `yaml:"secret,omitempty"` // for aws-secretsmanager, gcp-secretmanager; for gcp-service-account, the secret holding the key JSON
Region string `yaml:"region,omitempty"` // for aws-secretsmanager
Project string `yaml:"project,omitempty"` // for gcp-secretmanager, gcp-service-account
Version string `yaml:"version,omitempty"` // for gcp-secretmanager, gcp-service-account (default: "latest")
AppID string `yaml:"app_id,omitempty"` // for github-app source
InstallationID string `yaml:"installation_id,omitempty"` // for github-app source
PrivateKeyPath string `yaml:"private_key_path,omitempty"` // for github-app (PEM key), gcp-service-account (key JSON)
PrivateKeyEnv string `yaml:"private_key_env,omitempty"` // for github-app (PEM key), gcp-service-account (key JSON)
Scopes string `yaml:"scopes,omitempty"` // for gcp-service-account: space-separated OAuth scopes (default: cloud-platform)
// token-exchange (RFC 8693) fields
Endpoint string `yaml:"endpoint,omitempty"`
ClientID string `yaml:"client_id,omitempty"`
ClientSecret string `yaml:"client_secret,omitempty"`
ClientSecretEnv string `yaml:"client_secret_env,omitempty"`
SubjectHeader string `yaml:"subject_header,omitempty"`
SubjectFrom string `yaml:"subject_from,omitempty"`
SubjectTokenType string `yaml:"subject_token_type,omitempty"`
Resource string `yaml:"resource,omitempty"`
ActorTokenFrom string `yaml:"actor_token_from,omitempty"`
ActorTokenType string `yaml:"actor_token_type,omitempty"`
}
SourceConfig describes where to read a credential value from.
SourceConfig is used as a map key to deduplicate identical sources (see Server.setCredentials), so it must remain comparable: add list-valued fields as delimited strings (like Scopes), never slices, and avoid pointer fields, which would compile but silently break deduplication.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gatekeeper
command
|
|
|
skill-lint
command
Command skill-lint validates Agent Skills against the open specification at https://agentskills.io/specification.
|
Command skill-lint validates Agent Skills against the open specification at https://agentskills.io/specification. |
|
Package proxy provides a TLS-intercepting HTTP proxy for credential injection.
|
Package proxy provides a TLS-intercepting HTTP proxy for credential injection. |