Documentation
¶
Index ¶
- Constants
- func BuildHTTPClientConfig(hc HTTPClientConfig, insecureSkipVerify bool) (httpclient.Config, error)
- func BuildLatestVersionIndex(definitions map[string]models.PolicyDefinition) map[string]string
- func BuildXDSServerTLSConfig(cfg XDSServerTLSConfig) (*tls.Config, error)
- func ParseServerCiphers(raw string) ([]uint16, error)
- func ParseServerEcdhCurves(raw string) ([]tls.CurveID, error)
- func ParseServerTLSVersion(name string) (version uint16, ok bool)
- func ResolvePolicyVersion(definitions map[string]models.PolicyDefinition, ...) (string, error)
- func ValidateServerTLSVersions(minVersion, maxVersion string) error
- func ValidateXDSServerTLS(fieldPrefix string, cfg XDSServerTLSConfig) error
- type APIKeyConfig
- type APIValidator
- type AccessLogsConfig
- type AdminServerConfig
- type AnalyticsConfig
- type AnalyticsPublishersConfig
- type AuthConfig
- type AuthUser
- type BasicAuth
- type CollectorConfig
- type Config
- type ConfigDumpConfig
- type ControlPlaneConfig
- type Controller
- type DatabaseConfig
- type DownstreamTLS
- type EncryptionConfig
- type EncryptionKeyConfig
- type EventHubConfig
- type EventHubDatabaseConfig
- type GRPCEventServerConfig
- type HCMTimeouts
- type HTTPClientConfig
- type HTTPClientPoolingConfig
- type HTTPClientProxyConfig
- type HTTPClientProxyTLSConfig
- type HTTPClientSSRFConfig
- type HTTPClientTLSConfig
- type HTTPClientTimeoutsConfig
- type HTTPListenerConfig
- type IDPConfig
- type ImmutableGatewayConfig
- type LLMConfig
- type LLMValidator
- type LoggingConfig
- type LuaScriptConfig
- type MCPConfig
- type MCPValidator
- type MetricsConfig
- type MoesifPublisherConfig
- type Parser
- type PoliciesConfig
- type PolicyEngineConfig
- type PolicyEngineTLS
- type PolicyServerConfig
- type PolicyValidator
- func (pv *PolicyValidator) CoerceLLMPolicies(globalPolicies *[]api.Policy, operationPolicies *[]api.OperationPolicy, ...)
- func (pv *PolicyValidator) CoerceMCPProxyPolicies(config *api.MCPProxyConfiguration)
- func (pv *PolicyValidator) CoerceRestAPIPolicies(config *api.RestAPI)
- func (pv *PolicyValidator) ValidateLLMProviderPolicies(cfg *api.LLMProviderConfiguration) []ValidationError
- func (pv *PolicyValidator) ValidateLLMProxyPolicies(cfg *api.LLMProxyConfiguration) []ValidationError
- func (pv *PolicyValidator) ValidateMCPProxyPolicies(mcpConfig *api.MCPProxyConfiguration) []ValidationError
- func (pv *PolicyValidator) ValidateRestAPIPolicies(apiConfig *api.RestAPI) []ValidationError
- type PostgresConfig
- type PprofConfig
- type ProviderConfig
- type RouterConfig
- type RouterLuaConfig
- type RouterUpstream
- type SQLiteConfig
- type SecretValidator
- type ServerConfig
- type ServerTLSConfig
- type StorageConfig
- type SubscriptionsConfig
- type TracingConfig
- type TrafficLoggingConfig
- type UpstreamTLS
- type UpstreamTimeouts
- type VHostEntry
- type VHostsConfig
- type ValidationError
- type Validator
- type XDSServerTLSConfig
Constants ¶
const (
// DefaultLuaScriptPath is the default path for request transformation lua script
DefaultLuaScriptPath = "./lua/request_transformation.lua"
)
Variables ¶
This section is empty.
Functions ¶
func BuildHTTPClientConfig ¶
func BuildHTTPClientConfig(hc HTTPClientConfig, insecureSkipVerify bool) (httpclient.Config, error)
BuildHTTPClientConfig translates an HTTPClientConfig (sourced from controller.http_client in config.toml) into an httpkit httpclient.Config, mirroring every field the library exposes that has a natural TOML shape. insecureSkipVerify is threaded in separately from controller.controlplane.insecure_skip_verify — see HTTPClientConfig's doc comment for why that trust setting isn't duplicated here.
This is shared by every binary that loads this package's Config (gateway-controller and event-gateway-controller today) so the translation logic is implemented exactly once rather than copy-pasted per binary.
func BuildLatestVersionIndex ¶
func BuildLatestVersionIndex(definitions map[string]models.PolicyDefinition) map[string]string
BuildLatestVersionIndex scans policy definitions once and builds a map of policyName -> latest full semver. Used for O(1) empty-version resolution.
func BuildXDSServerTLSConfig ¶
func BuildXDSServerTLSConfig(cfg XDSServerTLSConfig) (*tls.Config, error)
BuildXDSServerTLSConfig turns a validated XDSServerTLSConfig into a *tls.Config enforcing mutual TLS: the server's own certificate, plus a client CA pool used to require and verify a client certificate (tls.RequireAndVerifyClientCert). This only performs the TLS handshake -- checking the verified peer's identity against AllowedClientIdentities is a separate authorization step the xDS server's stream callbacks must still perform (see pkg/tlsauth.VerifyStreamPeer); a certificate chaining to a trusted CA is not by itself authorization to reach this snapshot.
Callers should run ValidateXDSServerTLS first; this function re-validates version/cipher/curve fields defensively but does not check AllowedClientIdentities, which it never reads.
func ParseServerCiphers ¶
ParseServerCiphers parses a comma-separated list of Go crypto/tls cipher suite names (e.g. "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256") into the []uint16 consumed by tls.Config.CipherSuites. An empty string is valid and returns (nil, nil) — Go's own default suite set/order applies. Only affects TLS 1.2 (and below) connections; TLS 1.3 ignores this field.
func ParseServerEcdhCurves ¶
ParseServerEcdhCurves parses a comma-separated EcdhCurves preference list (e.g. "X25519MLKEM768,X25519,P-256") into the tls.CurveID slice consumed by tls.Config.CurvePreferences. Used both to fail config validation closed on an unrecognized curve name and to build the REST API TLS listener's config.
The name-to-tls.CurveID vocabulary is sourced from httpkit/tlsconfig (the shared, direction-neutral implementation); this function keeps its own wrapper for the "empty string is an error" behavior, which differs from tlsconfig.ParseCurvePreferences's "empty means use Go's defaults" stance — an explicit, always-on TLS listener config has no notion of "unset".
func ParseServerTLSVersion ¶
ParseServerTLSVersion converts a validated version name to its crypto/tls identifier. Callers should run ValidateServerTLSVersions first; an unrecognized name here returns ok=false rather than panicking.
func ResolvePolicyVersion ¶
func ResolvePolicyVersion(definitions map[string]models.PolicyDefinition, latestVersions map[string]string, name, version string) (string, error)
ResolvePolicyVersion resolves a policy version using the given definitions map. Only major-only versions (e.g., v1) are accepted; they are resolved to the unique full version (vX.Y.Z) for that policy name. Full semantic version (e.g., v1.0.0) is rejected. Used by both the validator and the derivation path. latestVersions is an optional pre-computed index (policyName -> latest full semver) for O(1) empty-version resolution; pass nil to fall back to scanning definitions.
func ValidateServerTLSVersions ¶
ValidateServerTLSVersions checks that min and max are both recognized version names and that min does not come after max. Unlike tlsconfig.ValidateVersionRange (which treats both-empty as "use Go's defaults"), this listener's config always requires both fields to name a real version — there is no "unset" state for an always-on TLS listener. tls.VersionTLSxx constants are monotonically increasing, so comparing the parsed values directly replaces a separate ordering table.
func ValidateXDSServerTLS ¶
func ValidateXDSServerTLS(fieldPrefix string, cfg XDSServerTLSConfig) error
ValidateXDSServerTLS validates an XDSServerTLSConfig block, a no-op when Enabled is false. fieldPrefix is the dotted config path used in error messages (e.g. "server.xds_tls" or "policy_server.tls").
Types ¶
type APIKeyConfig ¶
type APIKeyConfig struct {
APIKeysPerUserPerAPI int `koanf:"api_keys_per_user_per_api"` // Number of API keys allowed per user per API
Algorithm string `koanf:"algorithm"` // Hashing algorithm to use
MinKeyLength int `koanf:"min_key_length"` // Minimum length for external API key values
MaxKeyLength int `koanf:"max_key_length"` // Maximum length for external API key values
// Issuer identifies this gateway's portal; when non-empty, only API keys whose
// issuer field matches (or is null) will be accepted by the api-key-auth policy.
Issuer string `koanf:"issuer"`
}
APIKeyConfig represents the configuration for API keys
type APIValidator ¶
type APIValidator struct {
// contains filtered or unexported fields
}
APIValidator validates API configurations using rule-based validation
func NewAPIValidator ¶
func NewAPIValidator() *APIValidator
NewAPIValidator creates a new API configuration validator
func (*APIValidator) SetPolicyValidator ¶
func (v *APIValidator) SetPolicyValidator(policyValidator *PolicyValidator)
SetPolicyValidator sets the policy validator for validating policy references
func (*APIValidator) Validate ¶
func (v *APIValidator) Validate(config interface{}) []ValidationError
Validate performs comprehensive validation on a configuration It uses type switching to handle APIConfiguration specifically
func (*APIValidator) ValidateContext ¶
func (v *APIValidator) ValidateContext(context string) []ValidationError
validateContext validates the context path ValidateContext validates a resource's context path. Exported so it can be reused by other kinds' validators (e.g. an event-gateway-controller binary validating WebSubApi/WebBrokerApi configs).
type AccessLogsConfig ¶
type AccessLogsConfig struct {
Enabled bool `koanf:"enabled"`
Format string `koanf:"format"` // "json" or "text"
JSONFields map[string]string `koanf:"json_fields"` // JSON log format fields
TextFormat string `koanf:"text_format"` // Text log format template
}
AccessLogsConfig holds access log configuration
type AdminServerConfig ¶
type AdminServerConfig struct {
Enabled bool `koanf:"enabled"`
Port int `koanf:"port"`
AllowedIPs []string `koanf:"allowed_ips"`
Pprof PprofConfig `koanf:"pprof"`
ConfigDump ConfigDumpConfig `koanf:"config_dump"`
}
AdminServerConfig holds controller admin HTTP server configuration.
type AnalyticsConfig ¶
type AnalyticsConfig struct {
Enabled bool `koanf:"enabled"`
EnabledPublishers []string `koanf:"enabled_publishers"`
Publishers AnalyticsPublishersConfig `koanf:"publishers"`
// GRPCEventServerCfg is a deprecated alias. ALS transport tuning moved to
// [collector.server]; when set here it is migrated onto the collector during
// validation (with a warning). Prefer [collector.server].
GRPCEventServerCfg GRPCEventServerConfig `koanf:"grpc_event_server"`
// AllowPayloads, SendRequestBody and SendResponseBody are deprecated aliases.
// Body/header capture now lives under [collector]. When set, these are mapped
// onto collector.request_body / collector.response_body during
// validation (with a warning) for backward compatibility. Prefer the
// [collector] fields directly.
AllowPayloads bool `koanf:"allow_payloads"`
SendRequestBody bool `koanf:"send_request_body"`
SendResponseBody bool `koanf:"send_response_body"`
}
AnalyticsConfig holds analytics configuration
type AnalyticsPublishersConfig ¶
type AnalyticsPublishersConfig struct {
Moesif MoesifPublisherConfig `koanf:"moesif"`
}
AnalyticsPublishersConfig holds configuration for all analytics publishers
type AuthConfig ¶
AuthConfig holds authentication related configuration
type AuthUser ¶
type AuthUser struct {
Username string `koanf:"username"`
Password string `koanf:"password"` // plain or hashed value depending on PasswordHashed
PasswordHashed bool `koanf:"password_hashed"` // true when Password is a bcrypt hash
Roles []string `koanf:"roles"`
}
AuthUser describes a locally configured user
type CollectorConfig ¶
type CollectorConfig struct {
// RequestBody / ResponseBody capture request/response bodies into the
// collected event.
RequestBody bool `koanf:"request_body"`
ResponseBody bool `koanf:"response_body"`
// RequestHeaders / ResponseHeaders, when true, make the collector
// capture ALL request / response headers, so every API's headers flow into
// the collected event without attaching a per-API header policy.
RequestHeaders bool `koanf:"request_headers"`
ResponseHeaders bool `koanf:"response_headers"`
// IgnorePathPrefixes lists request path prefixes for which the collector
// produces no analytics event and no traffic-log line at all, as if the
// collector were disabled for that one request (e.g. health-check or
// metrics-scrape endpoints). Enforced by attaching an Envoy AccessLogFilter
// to the ALS access log (see xds.buildIgnorePathsAccessLogFilter) — Envoy
// itself never emits the log entry for a matching path, so the policy-engine
// never receives the request at all. Matched case-sensitively by prefix.
IgnorePathPrefixes []string `koanf:"ignore_path_prefixes"`
// Server tunes the Envoy→policy-engine gRPC access-log (ALS)
// transport that ships collected data. It is part of the collector and is
// configured under the shared [collector.server] section (the policy-engine reads
// the same section to configure its receiving ALS server).
Server GRPCEventServerConfig `koanf:"server"`
}
CollectorConfig holds the data-collection ("collector") configuration. The collector is the shared capture pipeline (the analytics system policy plus the Envoy→policy-engine ALS transport) that gathers request/response headers and bodies. It underpins every consumer of that data (analytics and traffic logging) and is implicitly active whenever a consumer is enabled — see Config.IsCollectorEnabled. This section tunes capture and transport; it has no on/off flag of its own.
type Config ¶
type Config struct {
Controller Controller `koanf:"controller"`
Router RouterConfig `koanf:"router"`
PolicyEngine map[string]interface{} `koanf:"policy_engine"`
PolicyConfigurations map[string]interface{} `koanf:"policy_configurations"`
Collector CollectorConfig `koanf:"collector"`
Analytics AnalyticsConfig `koanf:"analytics"`
TrafficLogging TrafficLoggingConfig `koanf:"traffic_logging"`
TracingConfig TracingConfig `koanf:"tracing"`
APIKey APIKeyConfig `koanf:"api_key"`
// Subscriptions controls application-level subscription behaviour for APIs.
// When nil, subscription validation system policy remains disabled.
Subscriptions *SubscriptionsConfig `koanf:"subscriptions"`
ImmutableGateway ImmutableGatewayConfig `koanf:"immutable_gateway"`
MCP MCPConfig `koanf:"mcp"`
}
Config holds all configuration for the gateway-controller
func LoadConfig ¶
LoadConfig loads configuration from one or more files layered over built-in defaults. Priority: Config files > Defaults.
Files are merged in the order given with last-wins precedence: a key set in a later file overrides the same key from an earlier file. Merge semantics follow koanf — nested tables (maps) deep-merge, while list/array values are replaced wholesale, not appended. A field may be overridden across files with a different representation — e.g. a numeric value in the base and an {{ env }} token (a string) in an overlay — and still resolve, because types are only checked after interpolation by the weakly-typed unmarshal (a non-coercible value still fails there).
{{ env }} / {{ file }} interpolation runs once, after all files are merged, so a token declared in an earlier file can be resolved by a later overlay.
func (*Config) IsAccessLogsEnabled ¶
IsAccessLogsEnabled returns true if access logs are enabled
func (*Config) IsCollectorEnabled ¶
IsCollectorEnabled reports whether the collector should run. The collector is implicit: it is active whenever any consumer of the collected data is enabled (analytics or stdout traffic logging), and off otherwise. When active, the controller injects the analytics system policy and configures Envoy's ALS sink.
type ConfigDumpConfig ¶
type ConfigDumpConfig struct {
Enabled bool `koanf:"enabled"`
}
ConfigDumpConfig gates the /config_dump endpoint served on the admin HTTP server. Disabled by default — /health and other admin routes are unaffected by this flag; when disabled, /config_dump returns 404 rather than a payload.
type ControlPlaneConfig ¶
type ControlPlaneConfig struct {
Host string `koanf:"host"` // Control plane hostname
Token string `koanf:"token"` // Registration token (api-key)
ReconnectInitial time.Duration `koanf:"reconnect_initial"` // Initial retry delay
ReconnectMax time.Duration `koanf:"reconnect_max"` // Maximum retry delay
PollingInterval time.Duration `koanf:"polling_interval"` // Reconciliation polling interval
InsecureSkipVerify bool `koanf:"insecure_skip_verify"` // Skip TLS certificate verification (insecure, dev/test only)
DeploymentSyncEnabled bool `koanf:"deployment_sync_enabled"` // Enable two-way artifact/deployment sync with the control plane: DP->CP push and CP->DP pull (default: true)
SyncBatchSize int `koanf:"sync_batch_size"` // Number of deployments to fetch per batch request during startup sync (default: 50)
// Optional worker pools that cap the concurrency of DP->CP sync work
APIMSyncPoolSize int `koanf:"apim_sync_pool_size"` // Workers for on-prem APIM bottom-up sync (0/unset = unlimited)
APIMSyncQueueSize int `koanf:"apim_sync_queue_size"` // Max pending APIM sync tasks when pool size > 0 (0/unset = unbounded)
AIWorkspaceSyncPoolSize int `koanf:"ai_workspace_sync_pool_size"` // Workers for platform-API (AI Workspace) artifact push (0/unset = unlimited)
AIWorkspaceSyncQueueSize int `koanf:"ai_workspace_sync_queue_size"` // Max pending artifact push tasks when pool size > 0 (0/unset = unbounded)
// OAuth2 credentials for on-prem APIM API import (for bottom-up API deployment)
ApimOAuth2ClientID string `koanf:"apim_oauth2_client_id"` // APIM OAuth2 client ID
ApimOAuth2ClientSecret string `koanf:"apim_oauth2_client_secret"` // APIM OAuth2 client secret
ApimOAuth2Username string `koanf:"apim_oauth2_username"` // APIM resource owner username
ApimOAuth2Password string `koanf:"apim_oauth2_password"` // APIM resource owner password
GatewayName string `koanf:"gateway_name"` // Name of the gateway for deployment configuration
}
ControlPlaneConfig holds control plane connection configuration
type Controller ¶
type Controller struct {
Server ServerConfig `koanf:"server"`
AdminServer AdminServerConfig `koanf:"admin_server"`
Storage StorageConfig `koanf:"storage"`
Logging LoggingConfig `koanf:"logging"`
ControlPlane ControlPlaneConfig `koanf:"controlplane"`
HTTPClient HTTPClientConfig `koanf:"http_client"`
PolicyServer PolicyServerConfig `koanf:"policy_server"`
Policies PoliciesConfig `koanf:"policies"`
LLM LLMConfig `koanf:"llm"`
Auth AuthConfig `koanf:"auth"`
Metrics MetricsConfig `koanf:"metrics"`
Encryption EncryptionConfig `koanf:"encryption"`
EventHub EventHubConfig `koanf:"event_hub"`
}
Controller holds the main configuration sections for the gateway-controller
type DatabaseConfig ¶
type DatabaseConfig struct {
Driver string `koanf:"driver"`
DSN string `koanf:"dsn"`
Path string `koanf:"path"`
Host string `koanf:"host"`
Port int `koanf:"port"`
Database string `koanf:"database"`
User string `koanf:"user"`
Password string `koanf:"password"`
ConnectTimeout time.Duration `koanf:"connect_timeout"`
MaxOpenConns int `koanf:"max_open_conns"`
MaxIdleConns int `koanf:"max_idle_conns"`
ConnMaxLifetime time.Duration `koanf:"conn_max_lifetime"`
ConnMaxIdleTime time.Duration `koanf:"conn_max_idle_time"`
ApplicationName string `koanf:"application_name"`
Options map[string]string `koanf:"options"`
}
DatabaseConfig holds unified database configuration for all SQL backends.
type DownstreamTLS ¶
type DownstreamTLS struct {
CertPath string `koanf:"cert_path"`
KeyPath string `koanf:"key_path"`
MinimumProtocolVersion string `koanf:"minimum_protocol_version"`
MaximumProtocolVersion string `koanf:"maximum_protocol_version"`
Ciphers string `koanf:"ciphers"`
// EcdhCurves is a comma-separated list of ECDH curves (e.g. "X25519,P-256"), most preferred
// first. Defaults to classical curves only — a hybrid post-quantum group (e.g.
// "X25519MLKEM768") can be added as the first preference, but only as an explicit opt-in per
// deployment: an already-running Envoy instance that doesn't recognize the curve name will
// NACK the xDS update and keep serving its last-known-good config, silently freezing that
// instance out of any further config changes until the operator fixes it. Confirm the
// deployed Envoy/BoringSSL build supports the group before enabling it.
EcdhCurves string `koanf:"ecdh_curves"`
}
DownstreamTLS holds downstream (listener) TLS configuration
type EncryptionConfig ¶
type EncryptionConfig struct {
Providers []ProviderConfig `koanf:"providers"`
}
EncryptionConfig holds encryption provider configuration
type EncryptionKeyConfig ¶
type EncryptionKeyConfig struct {
Version string `koanf:"version"` // Key identifier (e.g., "key-v1")
FilePath string `koanf:"file"` // Path to raw binary key file
}
EncryptionKeyConfig defines a single encryption key
type EventHubConfig ¶
type EventHubConfig struct {
PollInterval time.Duration `koanf:"poll_interval"`
CleanupInterval time.Duration `koanf:"cleanup_interval"`
RetentionPeriod time.Duration `koanf:"retention_period"`
Database EventHubDatabaseConfig `koanf:"database"`
}
EventHubConfig holds EventHub configuration for multi-replica sync
type EventHubDatabaseConfig ¶
type EventHubDatabaseConfig struct {
MaxOpenConns int `koanf:"max_open_conns"`
MaxIdleConns int `koanf:"max_idle_conns"`
ConnMaxLifetime time.Duration `koanf:"conn_max_lifetime"`
ConnMaxIdleTime time.Duration `koanf:"conn_max_idle_time"`
}
EventHubDatabaseConfig holds connection pool settings for the EventHub database connection
type GRPCEventServerConfig ¶
type GRPCEventServerConfig struct {
Mode string `koanf:"mode"` // Connection mode: "uds" (default) or "tcp"
// Port overrides the fixed Envoy→policy-engine ALS dial port (collector.ServerPort,
// 18090), used only in "tcp" mode. Deprecated: no longer defaulted here or documented
// in config-template.toml/Helm charts, so new deployments have no way to discover or
// set it. Kept solely so a config that already sets it explicitly keeps working;
// leave unset (0) to use the fixed port. Must match the policy-engine's
// collector.server.server_port override, or the two sides will fail to connect.
Port int `koanf:"port"`
BufferFlushInterval int `koanf:"buffer_flush_interval"` // Envoy buffer flush interval (nanoseconds)
BufferSizeBytes int `koanf:"buffer_size_bytes"` // Envoy buffer size
GRPCRequestTimeout int `koanf:"grpc_request_timeout"` // Envoy gRPC timeout (nanoseconds)
ShutdownTimeout time.Duration `koanf:"shutdown_timeout"` // ALS server shutdown timeout
PublicKeyPath string `koanf:"public_key_path"` // TLS public key path
PrivateKeyPath string `koanf:"private_key_path"` // TLS private key path
ALSPlainText bool `koanf:"als_plain_text"` // Use plaintext gRPC
MaxMessageSize int `koanf:"max_message_size"` // Max gRPC message size
MaxHeaderLimit int `koanf:"max_header_limit"` // Max header size
}
GRPCEventServerConfig holds configuration for gRPC event server (combines access log service and ALS server config)
type HCMTimeouts ¶
type HCMTimeouts struct {
RequestTimeout time.Duration `koanf:"request_timeout"` // HCM request_timeout (default 0s = disabled)
RequestHeadersTimeout time.Duration `koanf:"request_headers_timeout"` // HCM request_headers_timeout (default 0s = disabled)
StreamIdleTimeout time.Duration `koanf:"stream_idle_timeout"` // HCM stream_idle_timeout (default 5m)
IdleTimeout time.Duration `koanf:"idle_timeout"` // common_http_protocol_options.idle_timeout (default 1h)
}
HCMTimeouts holds HTTP Connection Manager (downstream/connection) timeouts.
type HTTPClientConfig ¶
type HTTPClientConfig struct {
Pooling HTTPClientPoolingConfig `koanf:"pooling"`
Timeouts HTTPClientTimeoutsConfig `koanf:"timeouts"`
TLS HTTPClientTLSConfig `koanf:"tls"`
Proxy HTTPClientProxyConfig `koanf:"proxy"`
SSRF HTTPClientSSRFConfig `koanf:"ssrf"`
}
HTTPClientConfig configures the single shared outbound *http.Client used by every control-plane / platform-API / on-prem-APIM call this process makes. It mirrors github.com/wso2/api-platform/httpkit/httpclient.Config field-for-field (see that package's own doc comments for full semantics) so every knob the library exposes that has a natural TOML shape is operator-configurable here, rather than hardcoded in main.go. The few fields httpclient.Config exposes that CANNOT be expressed in TOML — Go callback hooks (GetClientCertificate, VerifyPeerCertificate, VerifyConnection, ConnectHeader) and a pre-built *x509.CertPool / []*net.IPNet — are not represented here; a caller that needs those uses the httpclient package directly in code.
Timeouts.Overall is only a generous safety-net budget: real per-operation budgets (5s well-known discovery, 30s manifest/platform-API/on-prem-APIM calls, etc.) are enforced via a context.WithTimeout deadline at each call site, since http.Client.Do honors a request's context deadline independent of the client-level Timeout.
TLS.InsecureSkipVerify is intentionally NOT a field here — it is sourced from the single existing controller.controlplane.insecure_skip_verify setting (see main.go), which already governs this same trust decision for every one of this client's current callers (control plane, platform API, and on-prem APIM all copy that one field today). Duplicating it here would just create two settings that must always be kept in sync.
type HTTPClientPoolingConfig ¶
type HTTPClientPoolingConfig struct {
MaxIdleConns int `koanf:"max_idle_conns"`
MaxIdleConnsPerHost int `koanf:"max_idle_conns_per_host"`
MaxConnsPerHost int `koanf:"max_conns_per_host"`
IdleConnTimeout time.Duration `koanf:"idle_conn_timeout"`
KeepAlive time.Duration `koanf:"keep_alive"`
DisableKeepAlives bool `koanf:"disable_keep_alives"`
// EnableHTTP2 opts into HTTP/2. See httpclient.PoolingConfig.EnableHTTP2's doc comment
// on the HTTP/2 connection-coalescing caveat before enabling.
EnableHTTP2 bool `koanf:"enable_http2"`
}
HTTPClientPoolingConfig mirrors httpclient.PoolingConfig.
type HTTPClientProxyConfig ¶
type HTTPClientProxyConfig struct {
// Mode selects how the proxy is determined: "none" (default), "environment"
// (HTTP_PROXY/HTTPS_PROXY/NO_PROXY), or "url" (URL/Username/Password/NoProxy below).
Mode string `koanf:"mode"`
URL string `koanf:"url"`
Username string `koanf:"username"`
Password string `koanf:"password"`
NoProxy []string `koanf:"no_proxy"` // exact host, ".suffix", or CIDR entries; only used when mode == "url"
TLS HTTPClientProxyTLSConfig `koanf:"tls"`
// Egress states how origin-destination SSRF risk is handled when a forward proxy is
// also configured: "delegated" (trust the proxy's own egress controls) or
// "manual_connect" (validate the origin locally before ever issuing CONNECT). Must be
// set explicitly whenever Mode != "none" and SSRF.Enabled — httpclient.New fails
// closed at startup otherwise rather than silently choosing one.
Egress string `koanf:"egress"`
}
HTTPClientProxyConfig mirrors the TOML-expressible subset of httpclient.ProxyConfig.
type HTTPClientProxyTLSConfig ¶
type HTTPClientProxyTLSConfig struct {
RootCAFile string `koanf:"root_ca_file"`
ClientCertFile string `koanf:"client_cert_file"`
ClientKeyFile string `koanf:"client_key_file"`
// InsecureSkipVerify and InsecureSkipVerifyAcknowledged are deliberately separate
// fields: httpkit's own acknowledgement gate (httpclient.ProxyTLSConfig) requires an
// operator to opt into disabling verification twice, once per field, so a single
// "insecure_skip_verify = true" in TOML can't silently satisfy its own gate. Both must
// be explicitly set to true for InsecureSkipVerify to take effect.
InsecureSkipVerify bool `koanf:"insecure_skip_verify"`
InsecureSkipVerifyAcknowledged bool `koanf:"insecure_skip_verify_acknowledged"`
}
HTTPClientProxyTLSConfig mirrors httpclient.ProxyTLSConfig (the proxy's own TLS handshake, fully decoupled from the origin TLS handshake in HTTPClientTLSConfig).
type HTTPClientSSRFConfig ¶
type HTTPClientSSRFConfig struct {
Enabled bool `koanf:"enabled"`
// Preset selects a built-in netguard policy: "permit_private_block_metadata" (a
// backend that is normally private — a ClusterIP, a service-DNS name, localhost —
// stays reachable; only link-local/metadata/unspecified/multicast are refused) or
// "public_only" (stricter: every private/loopback/link-local/CGNAT address is
// refused, for a URL expected to point at the public internet). Required when Enabled
// is true. Custom CIDR allow/deny lists have no natural TOML shape and are not
// exposed here — use the httpclient/netguard packages directly in code for that.
Preset string `koanf:"preset"`
MaxRedirects int `koanf:"max_redirects"`
AllowedSchemes []string `koanf:"allowed_schemes"` // empty defaults to {"https"}
}
HTTPClientSSRFConfig mirrors the TOML-expressible subset of httpclient.SSRFConfig. Off by default: this shared client's current callers (control plane, platform API, on-prem APIM) all target a single fixed, operator-configured host, not a user/tenant-supplied URL — the scenario ssrf-prevention.md targets — so there is nothing to guard against today. Exposed for completeness and for any future caller of this shared client that fetches a tenant-supplied URL.
type HTTPClientTLSConfig ¶
type HTTPClientTLSConfig struct {
MinVersion string `koanf:"min_version"` // one of "TLS1_0".."TLS1_3"
MaxVersion string `koanf:"max_version"` // one of "TLS1_0".."TLS1_3"
CipherSuites string `koanf:"cipher_suites"` // comma-separated Go crypto/tls cipher suite names; TLS 1.2 and below only
CurvePreferences string `koanf:"curve_preferences"` // comma-separated, e.g. "X25519MLKEM768,X25519,P-256"
RootCAFile string `koanf:"root_ca_file"` // PEM CA bundle; empty uses the system root pool
ClientCertFile string `koanf:"client_cert_file"` // mTLS to the origin; both cert and key must be set together
ClientKeyFile string `koanf:"client_key_file"`
}
HTTPClientTLSConfig mirrors the TOML-expressible subset of httpclient.TLSConfig.
type HTTPClientTimeoutsConfig ¶
type HTTPClientTimeoutsConfig struct {
Overall time.Duration `koanf:"overall"` // safety-net only; see HTTPClientConfig's doc comment
Dial time.Duration `koanf:"dial"`
TLSHandshake time.Duration `koanf:"tls_handshake"`
ResponseHeader time.Duration `koanf:"response_header"`
ExpectContinue time.Duration `koanf:"expect_continue"`
// MaxResponseBytes bounds a response body. 0 = package default (10MiB). A negative
// value is rejected by BuildHTTPClientConfig rather than disabling the bound.
MaxResponseBytes int64 `koanf:"max_response_bytes"`
}
HTTPClientTimeoutsConfig mirrors httpclient.TimeoutsConfig.
type HTTPListenerConfig ¶
type HTTPListenerConfig struct {
ServerHeaderTransformation string `koanf:"server_header_transformation"` // Options: "APPEND_IF_ABSENT", "OVERWRITE", "PASS_THROUGH"
ServerHeaderValue string `koanf:"server_header_value"` // Custom value for the Server header
Timeouts HCMTimeouts `koanf:"timeouts"` // HTTP Connection Manager (downstream) timeouts
PerConnectionBufferLimitBytes uint32 `koanf:"per_connection_buffer_limit_bytes"` // Downstream per-connection buffer limit in bytes
DisablePathNormalization bool `koanf:"disable_path_normalization"`
PathWithEscapedSlashesAction string `koanf:"path_with_escaped_slashes_action"` // Options: "KEEP_UNCHANGED", "REJECT_REQUEST", "UNESCAPE_AND_REDIRECT", "UNESCAPE_AND_FORWARD"
}
HTTPListenerConfig holds HTTP listener related configuration of an API
type IDPConfig ¶
type IDPConfig struct {
Enabled bool `koanf:"enabled"`
JWKSURL string `koanf:"jwks_url"`
Issuer string `koanf:"issuer"`
RolesClaim string `koanf:"roles_claim"`
RoleMapping map[string][]string `koanf:"role_mapping"` // local role -> idp roles
Audience []string `koanf:"audience"`
}
IDPConfig describes an external identity provider for JWT validation
type ImmutableGatewayConfig ¶
type ImmutableGatewayConfig struct {
Enabled bool `koanf:"enabled"`
ArtifactsDir string `koanf:"artifacts_dir"`
}
ImmutableGatewayConfig holds configuration for immutable gateway mode. When enabled, the gateway loads all API artifacts from the filesystem on startup and rejects all mutating management API operations (POST, PUT, DELETE) at runtime.
type LLMConfig ¶
type LLMConfig struct {
TemplateDefinitionsPath string `koanf:"template_definitions_path"`
}
type LLMValidator ¶
type LLMValidator struct {
// contains filtered or unexported fields
}
LLMValidator validates LLM-related configurations (provider templates, providers, proxies) It uses type switching to handle different LLM configuration types
func NewLLMValidator ¶
func NewLLMValidator() *LLMValidator
NewLLMValidator creates a new LLM configuration validator
func (*LLMValidator) Validate ¶
func (v *LLMValidator) Validate(config interface{}) []ValidationError
Validate performs comprehensive validation on a configuration It uses type switching to handle different LLM configuration types: - LLMProviderTemplate (for /llm-provider-templates) - LLMProvider (for /llm-providers) - LLMProxy (for /llm-proxies)
type LoggingConfig ¶
type LoggingConfig struct {
Level string `koanf:"level"` // "debug", "info", "warn", "error"
Format string `koanf:"format"` // "json" (default) or "text"
}
LoggingConfig holds logging configuration
type LuaScriptConfig ¶
type LuaScriptConfig struct {
ScriptPath string `koanf:"script_path"`
}
LuaScriptConfig holds Lua script path configuration.
type MCPConfig ¶
type MCPConfig struct {
// AppendResourcePathToBackend preserves the legacy behaviour where the "/mcp"
// gateway resource path is appended to the MCP backend upstream path. Older
// gateway versions forwarded a request for "<context>/mcp" to "<upstream>/mcp".
// The current default forwards to exactly the configured upstream path (the
// upstream is expected to be the full MCP endpoint URL). Enable this only if
// existing MCP API definitions rely on the "/mcp" suffix being appended to the
// backend.
AppendResourcePathToBackend bool `koanf:"append_resource_path_to_backend"`
}
MCPConfig holds configuration for MCP (Model Context Protocol) proxies.
type MCPValidator ¶
type MCPValidator struct {
// contains filtered or unexported fields
}
MCPValidator validates API configurations using rule-based validation
func NewMCPValidator ¶
func NewMCPValidator() *MCPValidator
NewMCPValidator creates a new API configuration validator
func (*MCPValidator) Validate ¶
func (v *MCPValidator) Validate(config any) []ValidationError
Validate performs comprehensive validation on a configuration It uses type switching to handle MCPProxyConfiguration specifically
func (*MCPValidator) WithPolicyValidator ¶
func (v *MCPValidator) WithPolicyValidator(pv *PolicyValidator) *MCPValidator
WithPolicyValidator sets the policy validator on the MCPValidator and returns it for chaining
type MetricsConfig ¶
type MetricsConfig struct {
// Enabled indicates whether the metrics server should be started
Enabled bool `koanf:"enabled"`
// Port is the port for the metrics HTTP server
Port int `koanf:"port"`
}
MetricsConfig holds Prometheus metrics server configuration
type MoesifPublisherConfig ¶
type MoesifPublisherConfig struct {
ApplicationID string `koanf:"application_id"`
BaseURL string `koanf:"moesif_base_url"`
PublishInterval int `koanf:"publish_interval"`
EventQueueSize int `koanf:"event_queue_size"`
BatchSize int `koanf:"batch_size"`
TimerWakeupSeconds int `koanf:"timer_wakeup_seconds"`
}
MoesifPublisherConfig holds Moesif-specific configuration
type Parser ¶
type Parser struct{}
Parser handles parsing of API configuration files
func (*Parser) ParseAPIConfigYAML ¶
type PoliciesConfig ¶
type PoliciesConfig struct {
DefinitionsPath string `koanf:"definitions_path"` // Directory containing policy definitions
BuildManifestPath string `koanf:"build_manifest_path"` // Path to build-manifest.yaml for custom policy detection
}
PoliciesConfig holds policy-related configuration
type PolicyEngineConfig ¶
type PolicyEngineConfig struct {
Mode string `koanf:"mode"` // Connection mode: "uds" (default) or "tcp"
Host string `koanf:"host"` // Policy engine hostname/IP (TCP mode only)
Port uint32 `koanf:"port"` // Policy engine ext_proc port (TCP mode only)
TimeoutMs uint32 `koanf:"timeout_ms"`
MessageTimeoutMs uint32 `koanf:"message_timeout_ms"`
TLS PolicyEngineTLS `koanf:"tls"` // TLS configuration (TCP mode only)
}
PolicyEngineConfig holds policy engine ext_proc filter configuration
type PolicyEngineTLS ¶
type PolicyEngineTLS struct {
Enabled bool `koanf:"enabled"` // Enable TLS for policy engine connection
CertPath string `koanf:"cert_path"` // Path to client certificate (mTLS)
KeyPath string `koanf:"key_path"` // Path to client private key (mTLS)
CAPath string `koanf:"ca_path"` // Path to CA certificate for server validation
ServerName string `koanf:"server_name"` // SNI server name (optional, defaults to host)
SkipVerify bool `koanf:"skip_verify"` // Skip server certificate verification (insecure, dev only)
}
PolicyEngineTLS holds policy engine TLS configuration
type PolicyServerConfig ¶
type PolicyServerConfig struct {
Port int `koanf:"port"`
TLS XDSServerTLSConfig `koanf:"tls"`
}
PolicyServerConfig holds policy xDS server-related configuration
type PolicyValidator ¶
type PolicyValidator struct {
// contains filtered or unexported fields
}
PolicyValidator validates policies referenced in API configurations
func NewPolicyValidator ¶
func NewPolicyValidator(policyDefinitions map[string]models.PolicyDefinition) *PolicyValidator
NewPolicyValidator creates a new policy validator
func (*PolicyValidator) CoerceLLMPolicies ¶
func (pv *PolicyValidator) CoerceLLMPolicies(globalPolicies *[]api.Policy, operationPolicies *[]api.OperationPolicy, legacyPolicies *[]api.LLMPolicy)
CoerceLLMPolicies coerces policy param strings to their schema-declared types for any LLM config (provider or proxy). Pass the three policy collections from the spec.
func (*PolicyValidator) CoerceMCPProxyPolicies ¶
func (pv *PolicyValidator) CoerceMCPProxyPolicies(config *api.MCPProxyConfiguration)
CoerceMCPProxyPolicies coerces policy param strings to their schema-declared types for an MCPProxyConfiguration. Must be called after template rendering in the event listener.
func (*PolicyValidator) CoerceRestAPIPolicies ¶
func (pv *PolicyValidator) CoerceRestAPIPolicies(config *api.RestAPI)
CoerceRestAPIPolicies coerces policy param strings to their schema-declared types for a RestAPI config. Must be called after template rendering (e.g. in the event listener) so the in-memory store and xDS snapshot receive typed values, not rendered strings.
func (*PolicyValidator) ValidateLLMProviderPolicies ¶
func (pv *PolicyValidator) ValidateLLMProviderPolicies(cfg *api.LLMProviderConfiguration) []ValidationError
ValidateLLMProviderPolicies validates all policy references in an LLM provider configuration. Mirrors ValidateRestAPIPolicies: it checks the user-authored global, operation and (deprecated) policy references against the loaded policy definitions. Policies injected later by the LLM->RestAPI transform (e.g. upstream auth) are intentionally not validated here so the semantics match the REST API path, which only validates user-authored policies.
func (*PolicyValidator) ValidateLLMProxyPolicies ¶
func (pv *PolicyValidator) ValidateLLMProxyPolicies(cfg *api.LLMProxyConfiguration) []ValidationError
ValidateLLMProxyPolicies validates all policy references in an LLM proxy configuration. See ValidateLLMProviderPolicies for the rationale on validating the source configuration.
func (*PolicyValidator) ValidateMCPProxyPolicies ¶
func (pv *PolicyValidator) ValidateMCPProxyPolicies(mcpConfig *api.MCPProxyConfiguration) []ValidationError
ValidateMCPProxyPolicies validates all policies in an MCP proxy configuration
func (*PolicyValidator) ValidateRestAPIPolicies ¶
func (pv *PolicyValidator) ValidateRestAPIPolicies(apiConfig *api.RestAPI) []ValidationError
ValidateRestAPIPolicies validates all policies in a REST API configuration
type PostgresConfig ¶
type PostgresConfig struct {
DSN string `koanf:"dsn"`
Host string `koanf:"host"`
Port int `koanf:"port"`
Database string `koanf:"database"`
User string `koanf:"user"`
Password string `koanf:"password"`
SSLMode string `koanf:"sslmode"`
ConnectTimeout time.Duration `koanf:"connect_timeout"`
MaxOpenConns int `koanf:"max_open_conns"`
MaxIdleConns int `koanf:"max_idle_conns"`
ConnMaxLifetime time.Duration `koanf:"conn_max_lifetime"`
ConnMaxIdleTime time.Duration `koanf:"conn_max_idle_time"`
ApplicationName string `koanf:"application_name"`
}
PostgresConfig holds PostgreSQL-specific configuration.
type PprofConfig ¶
type PprofConfig struct {
// Enabled registers the /debug/pprof/* handlers on the admin server.
Enabled bool `koanf:"enabled"`
// BlockProfileRate is passed to runtime.SetBlockProfileRate (0 = block profiling off).
BlockProfileRate int `koanf:"block_profile_rate"`
// MutexProfileFraction is passed to runtime.SetMutexProfileFraction (0 = mutex profiling off).
MutexProfileFraction int `koanf:"mutex_profile_fraction"`
}
PprofConfig gates the Go runtime profiling endpoints (net/http/pprof) served on the admin HTTP server. Disabled by default; when disabled the /debug/pprof/* routes are not registered at all (they return 404, not 403).
type ProviderConfig ¶
type ProviderConfig struct {
Type string `koanf:"type"` // "aesgcm"
Keys []EncryptionKeyConfig `koanf:"keys"`
}
ProviderConfig defines configuration for a single encryption provider
type RouterConfig ¶
type RouterConfig struct {
AccessLogs AccessLogsConfig `koanf:"access_logs"`
ListenerPort int `koanf:"listener_port"`
HTTPSEnabled bool `koanf:"https_enabled"`
HTTPSPort int `koanf:"https_port"`
GatewayHost string `koanf:"gateway_host"`
Lua RouterLuaConfig `koanf:"lua"`
LuaScriptPath string `koanf:"lua_script_path"` // Deprecated: use router.lua.request_transformation.script_path
// Upstream holds upstream-side configuration (TLS and timeouts: route, idle, connect)
Upstream RouterUpstream `koanf:"upstream"`
PolicyEngine PolicyEngineConfig `koanf:"policy_engine"`
DownstreamTLS DownstreamTLS `koanf:"downstream_tls"`
VHosts VHostsConfig `koanf:"vhosts"`
TracingServiceName string `koanf:"tracing_service_name"`
// HTTPListener configuration
HTTPListener HTTPListenerConfig `koanf:"http_listener"`
}
RouterConfig holds router (Envoy) related configuration
type RouterLuaConfig ¶
type RouterLuaConfig struct {
RequestTransformation LuaScriptConfig `koanf:"request_transformation"`
}
RouterLuaConfig holds Lua related configurations.
type RouterUpstream ¶
type RouterUpstream struct {
TLS UpstreamTLS `koanf:"tls"`
Timeouts UpstreamTimeouts `koanf:"timeouts"`
}
RouterUpstream holds upstream-side configuration (TLS and timeouts for Envoy upstream).
type SQLiteConfig ¶
type SQLiteConfig struct {
Path string `koanf:"path"` // Path to SQLite database file
}
SQLiteConfig holds SQLite-specific configuration
type SecretValidator ¶
type SecretValidator struct {
// contains filtered or unexported fields
}
SecretValidator validates Secret configurations using rule-based validation
func NewSecretValidator ¶
func NewSecretValidator() *SecretValidator
NewSecretValidator creates a new Secret configuration validator
func (*SecretValidator) Validate ¶
func (v *SecretValidator) Validate(config any) []ValidationError
Validate performs comprehensive validation on a configuration
type ServerConfig ¶
type ServerConfig struct {
APIPort int `koanf:"api_port"`
XDSPort int `koanf:"xds_port"`
ShutdownTimeout time.Duration `koanf:"shutdown_timeout"`
GatewayID string `koanf:"gateway_id"`
SkipInvalidDeploymentsOnStartup bool `koanf:"skip_invalid_deployments_on_startup"`
// TLS starts a second, TLS-only listener on TLS.Port serving the same
// REST management API as the plaintext listener on APIPort. Off by
// default.
TLS ServerTLSConfig `koanf:"tls"`
// XDSTLS switches the main xDS gRPC server (serving Envoy, on XDSPort)
// from plaintext to mutual TLS. Unlike TLS above, this does not add a
// second listener -- XDSPort itself starts speaking mTLS. Off by
// default; see XDSServerTLSConfig for why xDS has no server-only mode.
XDSTLS XDSServerTLSConfig `koanf:"xds_tls"`
// ReadTimeout, ReadHeaderTimeout, WriteTimeout, and IdleTimeout bound the
// REST management API's http.Server (both the plaintext listener on
// APIPort and the TLS listener on TLS.Port) so a slow or malicious
// client can't hold a connection open indefinitely (Slowloris-style
// resource exhaustion). MaxHeaderBytes bounds header size the same way.
// All five must be non-zero -- defaultConfig supplies safe defaults.
ReadTimeout time.Duration `koanf:"read_timeout"`
ReadHeaderTimeout time.Duration `koanf:"read_header_timeout"`
WriteTimeout time.Duration `koanf:"write_timeout"`
IdleTimeout time.Duration `koanf:"idle_timeout"`
MaxHeaderBytes int `koanf:"max_header_bytes"`
}
ServerConfig holds server-related configuration
type ServerTLSConfig ¶
type ServerTLSConfig struct {
// Enabled starts the TLS listener on Port. Off by default: no
// certificate is provisioned by default, and the plaintext listener
// keeps working either way.
Enabled bool `koanf:"enabled"`
// Port is the port for the TLS REST API listener. Must differ from every
// other configured controller port (server.api_port, server.xds_port,
// admin_server.port, metrics.port).
Port int `koanf:"port"`
// CertPath and KeyPath are the PEM-encoded server certificate and
// private key for the TLS listener. Required when Enabled.
CertPath string `koanf:"cert_path"`
KeyPath string `koanf:"key_path"`
// MinimumProtocolVersion and MaximumProtocolVersion bound the negotiated
// TLS version: one of "TLS1_0", "TLS1_1", "TLS1_2", "TLS1_3". Same
// vocabulary as router.downstream_tls/upstream_tls for consistency
// within the shared config file.
MinimumProtocolVersion string `koanf:"minimum_protocol_version"`
MaximumProtocolVersion string `koanf:"maximum_protocol_version"`
// Ciphers is a comma-separated list of Go crypto/tls cipher suite names
// (e.g. "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"), restricting which
// suites this listener will negotiate. Empty by default, meaning Go's
// own secure default set/order applies. Only affects TLS 1.2 and below —
// TLS 1.3 suite selection is not configurable in Go's crypto/tls.
//
// Note this is a different naming scheme than router.downstream_tls's
// ciphers field (OpenSSL/BoringSSL names like
// "ECDHE-ECDSA-AES128-GCM-SHA256"): this listener is served by Go's own
// crypto/tls, not Envoy, so it uses Go's canonical cipher suite names —
// see crypto/tls.CipherSuites for the supported list.
Ciphers string `koanf:"ciphers"`
// EcdhCurves is a comma-separated list of TLS 1.3 key-exchange groups,
// most preferred first. Defaults to the hybrid post-quantum group
// ("X25519MLKEM768", FIPS 203 ML-KEM-768 + X25519) first, with classical
// fallbacks after (e.g. "X25519MLKEM768,X25519,P-256").
//
// Unlike router.downstream_tls/upstream_tls's EcdhCurves (classical-only
// by default), this listener is served directly by this process's own Go
// crypto/tls (1.23+ implements X25519MLKEM768 natively) rather than
// pushed as xDS config to a separate Envoy process, so defaulting to the
// hybrid group here carries none of the "already-running peer NACKs the
// update" risk documented on those fields — TLS 1.3 negotiation simply
// falls back to a later classical entry in this same list for a client
// that doesn't offer the hybrid group.
EcdhCurves string `koanf:"ecdh_curves"`
}
ServerTLSConfig holds configuration for an additional TLS listener for the REST management API. It is served alongside — not instead of — the plaintext listener on ServerConfig.APIPort, so enabling it never breaks an existing plaintext deployment. Same shape and naming conventions as policy-engine's AdminTLSConfig (gateway-runtime/policy-engine/internal/config) — keep the two in sync if either changes, they are independent implementations (different Go modules) of the same pattern.
type StorageConfig ¶
type StorageConfig struct {
Type string `koanf:"type"` // "sqlite", "postgres", or "sqlserver"
Database *DatabaseConfig `koanf:"database"` // Global database configuration
SQLite SQLiteConfig `koanf:"sqlite"` // Legacy SQLite configuration (backward compatibility)
Postgres PostgresConfig `koanf:"postgres"` // Legacy PostgreSQL configuration (backward compatibility)
}
StorageConfig holds storage-related configuration
func (StorageConfig) EffectivePostgresConfig ¶
func (s StorageConfig) EffectivePostgresConfig() PostgresConfig
EffectivePostgresConfig resolves PostgreSQL config with precedence: storage.database.* > storage.postgres.*.
func (StorageConfig) EffectiveSQLServerConfig ¶
func (s StorageConfig) EffectiveSQLServerConfig() DatabaseConfig
EffectiveSQLServerConfig resolves SQL Server config from the global database section.
func (StorageConfig) EffectiveSQLitePath ¶
func (s StorageConfig) EffectiveSQLitePath() string
EffectiveSQLitePath resolves SQLite path with precedence: storage.database.path > storage.sqlite.path.
func (StorageConfig) SQLServerEncrypt ¶
func (s StorageConfig) SQLServerEncrypt() string
SQLServerEncrypt resolves sqlserver encrypt option from storage.database.options.
func (StorageConfig) SQLServerTrustServerCertificate ¶
func (s StorageConfig) SQLServerTrustServerCertificate() bool
SQLServerTrustServerCertificate resolves sqlserver trust flag from storage.database.options.
type SubscriptionsConfig ¶
type SubscriptionsConfig struct {
// EnableValidation toggles automatic injection of the subscriptionValidation
// system policy into API policy chains.
EnableValidation bool `koanf:"enable_validation"`
}
SubscriptionsConfig holds configuration for application-level subscriptions.
type TracingConfig ¶
type TracingConfig struct {
// Enabled toggles tracing on/off
Enabled bool `koanf:"enabled"`
// Endpoint is the OTLP gRPC endpoint (host:port)
Endpoint string `koanf:"endpoint"`
// Insecure indicates whether to use an insecure connection (no TLS)
Insecure bool `koanf:"insecure"`
// ServiceVersion is the service version reported to the tracing backend
ServiceVersion string `koanf:"service_version"`
// BatchTimeout is the export batch timeout
BatchTimeout time.Duration `koanf:"batch_timeout"`
// MaxExportBatchSize is the maximum batch size for exports
MaxExportBatchSize int `koanf:"max_export_batch_size"`
// SamplingRate is the ratio of requests to sample (0.0 to 1.0)
// 1.0 = sample all requests, 0.1 = sample 10% of requests
// If set to 0 or not specified, defaults to 1.0 (sample all)
SamplingRate float64 `koanf:"sampling_rate"`
// ResourceAttributes are OpenTelemetry resource attributes attached to every
// exported span, e.g. {"deployment.environment": "prod"}. The controller
// translates these into the router's (Envoy's) static_config resource
// detector; the policy-engine applies the same map to its own spans, so one
// block covers both components. Attributes discovered from the environment
// (OTEL_RESOURCE_ATTRIBUTES) are still honoured, but these take precedence.
ResourceAttributes map[string]string `koanf:"resource_attributes"`
}
TracingConfig holds OpenTelemetry tracing configuration
type TrafficLoggingConfig ¶
type TrafficLoggingConfig struct {
// Enabled turns stdout JSON traffic logging on. Enabling it implicitly activates
// the collector (see Config.IsCollectorEnabled).
Enabled bool `koanf:"enabled"`
}
TrafficLoggingConfig mirrors the policy-engine's stdout traffic-logging consumer. The controller only needs to know whether it is enabled, so that the collector (system policy + ALS sink) is activated when traffic logging is on even if analytics is off. Presentation keys (masked_headers, max_payload_size) are policy-engine-only and intentionally not bound here.
type UpstreamTLS ¶
type UpstreamTLS struct {
MinimumProtocolVersion string `koanf:"minimum_protocol_version"`
MaximumProtocolVersion string `koanf:"maximum_protocol_version"`
Ciphers string `koanf:"ciphers"`
// EcdhCurves is a comma-separated list of ECDH curves (e.g. "X25519,P-256"), most preferred
// first. Defaults to classical curves only — a hybrid post-quantum group (e.g.
// "X25519MLKEM768") can be added as the first preference, but only as an explicit opt-in per
// deployment: an already-running Envoy instance that doesn't recognize the curve name will
// NACK the xDS update and keep serving its last-known-good config, silently freezing that
// instance out of any further config changes until the operator fixes it. Confirm the
// deployed Envoy/BoringSSL build supports the group before enabling it.
EcdhCurves string `koanf:"ecdh_curves"`
TrustedCertPath string `koanf:"trusted_cert_path"`
CustomCertsPath string `koanf:"custom_certs_path"` // Directory containing custom trusted certificates
VerifyHostName bool `koanf:"verify_host_name"`
DisableSslVerification bool `koanf:"disable_ssl_verification"`
}
UpstreamTLS holds TLS configuration for upstream connections.
type UpstreamTimeouts ¶
type UpstreamTimeouts struct {
RouteTimeoutMs uint32 `koanf:"route_timeout_ms"`
RouteIdleTimeoutMs uint32 `koanf:"route_idle_timeout_ms"`
ConnectTimeoutMs uint32 `koanf:"connect_timeout_ms"`
}
UpstreamTimeouts holds upstream timeout configurations (values in milliseconds).
type VHostEntry ¶
type VHostsConfig ¶
type VHostsConfig struct {
Main VHostEntry `koanf:"main"`
Sandbox VHostEntry `koanf:"sandbox"`
}
VHostsConfig for vhosts configuration
type ValidationError ¶
ValidationError represents a field-level validation error
func ValidateLabels ¶
func ValidateLabels(labels map[string]string) []ValidationError
ValidateLabels validates that label keys do not contain any whitespace This is a common validation used across all configuration types
func ValidateMetadata ¶
func ValidateMetadata(metadata *api.Metadata) []ValidationError
ValidateMetadata is a helper function to validate metadata This can be used by validator implementations
type Validator ¶
type Validator interface {
Validate(config interface{}) []ValidationError
}
Validator is an interface for validating configurations This allows for different validation strategies (API, LLM, MCP, etc.) Each validator implementation handles different configuration types using type switching
type XDSServerTLSConfig ¶
type XDSServerTLSConfig struct {
// Enabled switches the xDS server from plaintext to mutual TLS on its
// existing port (server.xds_port or policy_server.port) -- there is no
// second listener the way ServerTLSConfig adds one for the REST API,
// since a gRPC server serves one credential type per port.
Enabled bool `koanf:"enabled"`
// CertFile and KeyFile are the PEM-encoded server certificate and
// private key this xDS server presents to connecting clients. Required
// when Enabled.
CertFile string `koanf:"cert_file"`
KeyFile string `koanf:"key_file"`
// ClientCAFile is a PEM bundle of CA certificates trusted to sign a
// connecting client's certificate (Envoy's or the policy-engine's).
// Required when Enabled -- this is what makes the handshake mutual
// rather than server-only.
ClientCAFile string `koanf:"client_ca_file"`
// AllowedClientIdentities is an explicit allowlist of accepted peer
// certificate identities: a certificate's first SAN URI (e.g. a SPIFFE
// ID) if present, otherwise its Subject CommonName -- see
// pkg/tlsauth.PeerIdentity. A client certificate that chains to a
// trusted CA is not by itself authorization to reach this snapshot; at
// least one identity is required when Enabled, so this can't be
// silently left as a no-op allowlist (go-control-plane-xds-security.md
// directive 2).
AllowedClientIdentities []string `koanf:"allowed_client_identities"`
// MinimumProtocolVersion and MaximumProtocolVersion bound the
// negotiated TLS version: one of "TLS1_0", "TLS1_1", "TLS1_2", "TLS1_3".
// Same vocabulary as ServerTLSConfig/router.downstream_tls for
// consistency within this file.
MinimumProtocolVersion string `koanf:"minimum_protocol_version"`
MaximumProtocolVersion string `koanf:"maximum_protocol_version"`
// Ciphers is a comma-separated list of Go crypto/tls cipher suite names
// restricting which suites this server negotiates. Empty by default --
// Go's own secure default set/order applies. Only affects TLS 1.2 and
// below; TLS 1.3 suite selection is not configurable in Go's crypto/tls.
Ciphers string `koanf:"ciphers"`
// EcdhCurves is a comma-separated list of TLS 1.3 key-exchange groups,
// most preferred first. Defaults to the hybrid post-quantum group
// ("X25519MLKEM768", FIPS 203 ML-KEM-768 + X25519) first, with classical
// fallbacks after -- this server is Go's own crypto/tls (1.23+
// implements X25519MLKEM768 natively), so an Envoy/policy-engine peer
// that doesn't support the group simply falls back to a later classical
// entry in this same list.
EcdhCurves string `koanf:"ecdh_curves"`
}
XDSServerTLSConfig holds mutual-TLS configuration for an xDS gRPC server: the main Envoy-facing ADS/SDS server on server.xds_port, and the policy-engine-facing server on policy_server.port. Off by default -- both servers keep working in plaintext either way, consistent with this repo's "PQC/TLS is optional-but-supported, not mandatory" posture (see post-quantum-cryptography.md), since not every deployment's Envoy or policy-engine build is configured for mTLS yet.
Unlike ServerTLSConfig (the REST management API's TLS listener, which is server-only TLS), this type has no server-only mode: xDS is a control-plane channel that carries per-tenant API-key hashes, subscription state, and full policy chains, so authenticating only the server side is not sufficient (go-control-plane-xds-security.md directive 2). Whenever Enabled is true, ClientCAFile and AllowedClientIdentities are both required -- see ValidateXDSServerTLS.