Documentation
¶
Overview ¶
Package config holds the IAM service configuration, loaded from a config file (config.yaml, path via CONFIG_PATH) overlaid with environment variables and validated. It follows the komeet/go-server-toolkit pattern: a nested Config{Infra, Service} of structs carrying mapstructure / default / validate tags, populated by the generic LoadConfig[T].
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
DefaultEnvironment string `mapstructure:"default_environment" default:"live" validate:"required"`
AccessTTLSec int `mapstructure:"access_ttl_sec" default:"600" validate:"min=60"`
RefreshTTLSec int `mapstructure:"refresh_ttl_sec" default:"2592000" validate:"min=60"`
// MasterKey is the platform operator (master-key) credential. When empty the
// masterKey security scheme rejects every request — operator endpoints are
// disabled until a key is configured (set via MASTER_KEY / service.auth.master_key).
MasterKey string `mapstructure:"master_key" default:""`
// EncryptionKey is the base64-encoded 32-byte AES-256 key that encrypts
// reversible secrets at rest (signing-key PEMs, TOTP secrets). Empty disables
// at-rest encryption (passthrough). Set via SERVICE_AUTH_ENCRYPTION_KEY.
EncryptionKey string `mapstructure:"encryption_key" default:"" validate:"omitempty,base64"`
// SeedRoot, when true, ensures a root project exists on startup so the
// operator (master key) has something to manage. Development convenience;
// set via SERVICE_AUTH_SEED_ROOT.
SeedRoot bool `mapstructure:"seed_root" default:"false"`
}
Auth holds IAM token/issuer defaults applied when an environment does not override them.
type CORS ¶
type CORS struct {
AllowedOrigins []string `mapstructure:"allowed_origins"`
}
CORS is the browser cross-origin policy for runtime endpoints.
type Config ¶
type Config struct {
Infra Infrastructure `mapstructure:"infra"`
Service Service `mapstructure:"service"`
}
Config is the full IAM service configuration.
type HTTP ¶
type HTTP struct {
Addr string `mapstructure:"addr" default:":8080" validate:"required"`
ReadTimeoutSec int `mapstructure:"read_timeout_sec" default:"15" validate:"min=1"`
WriteTimeoutSec int `mapstructure:"write_timeout_sec" default:"30" validate:"min=1"`
ShutdownSec int `mapstructure:"shutdown_sec" default:"15" validate:"min=1"`
// ProbeAddr is the address for the liveness/readiness probe server. When set
// to a different address than Addr, probes are served on their own listener
// (a k8s sidecar port not exposed publicly); when empty or equal to Addr they
// are mounted under /healthz/ on the main server.
ProbeAddr string `mapstructure:"probe_addr" default:":8081"`
// TrustedProxies is the list of CIDR ranges (or bare IPs) of reverse
// proxies / load balancers in front of the service. The client IP is taken
// from X-Forwarded-For / X-Real-IP ONLY when the connecting peer is in this
// set; otherwise the real TCP peer (RemoteAddr) is used. Empty (default)
// means trust no proxy headers — required so a client cannot spoof its IP to
// bypass IP-keyed rate limiting. Set to the LB subnet in proxied deploys
// (e.g. "10.0.0.0/8"). Env: SERVICE_HTTP_TRUSTED_PROXIES (comma-separated).
TrustedProxies []string `mapstructure:"trusted_proxies"`
}
HTTP is the inbound HTTP server config.
type Infrastructure ¶
type Infrastructure struct {
Postgres Postgres `mapstructure:"postgres"`
}
Infrastructure is the external-dependency config (datastores, …).
type Logger ¶
type Logger struct {
Level string `mapstructure:"level" default:"info" validate:"oneof=debug info warn error"`
Format string `mapstructure:"format" default:"json" validate:"oneof=json text"`
}
Logger is the structured-logging config.
type Postgres ¶
type Postgres struct {
Host string `mapstructure:"host" default:"localhost" validate:"required,hostname|ip"`
Port int `mapstructure:"port" default:"5432" validate:"required,min=1,max=65535"`
Username string `mapstructure:"username" default:"iam" validate:"required"`
Password string `mapstructure:"password" default:"iam" validate:"required"`
Database string `mapstructure:"database" default:"iam" validate:"required"`
SSLMode string `mapstructure:"sslmode" default:"require" validate:"oneof=disable require verify-ca verify-full"`
LogLevel string `mapstructure:"log_level" default:"info" validate:"oneof=debug info warn error"`
}
Postgres is the connection config for the IAM store.