Documentation
¶
Overview ¶
Package config loads the identity service configuration from environment variables with the GATEWAY_ prefix.
This is the Go port of backend/api_gateway/config.py. It uses os.Getenv with typed defaults — no external config library needed. Sensitive values (secrets, encryption keys, client secrets) are never logged.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Server
GRPCPort int
ConnectPort int
MetricsPort int
// Persistence driver. Selects which Repository / DB
// implementation the binary wires up — "entdb" (default), "memory"
// for an in-process store useful for local dev, or "postgres"
// once the Postgres driver lands. Driven by GATEWAY_REPO_DRIVER.
RepoDriver string
// EntDB
EntDBAddress string
// Tenant
DefaultTenantID string
// Email service (internal gRPC)
EmailServiceHost string
EmailServicePort int
// JWT (RS256)
// JSON array: [{"kid":"k1","private_key_pem":"...","public_key_pem":"...","active":true}]
// If empty and running locally, an ephemeral RSA key is auto-generated.
JWTKeys string
JWTExpirySeconds int
// Refresh tokens
RefreshExpirySeconds int
// OAuth providers. Identity does the code exchange for these
// providers itself — see pkg/oauth. A provider is enabled only
// when BOTH the ID and secret are non-empty.
GoogleClientID string
GoogleClientSecret string
MicrosoftClientID string
MicrosoftClientSecret string
MicrosoftTenantID string
GitHubClientID string
GitHubClientSecret string
// Password
PasswordSignupEnabled bool
PasswordResetEnabled bool
PasswordResetExpirySeconds int
// TOTP (2FA)
// 32-byte key, base64-encoded. Required in prod; dev falls back to
// a deterministic throwaway key.
TOTPEncryptionKey string
TOTPIssuer string
// Login challenge (how long after password success user has to complete 2FA)
LoginChallengeExpirySeconds int
// WebAuthn / Passkeys
PasskeyRPID string
PasskeyRPName string
PasskeyOrigin string
PasskeyChallengeExpirySeconds int
// QR Login (cross-device authorization)
QRLoginBaseURL string
QRLoginExpirySeconds int
// Login security (failed-login lockout)
LoginMaxFailedAttempts int
LoginLockoutSeconds int
// Default email domain
DefaultEmailDomain string
// CORS
AllowedOrigins string
// Cookie settings
CookieDomain string
CookieSecure bool
CookieSameSite string
// Dev-only
AuthAllowLocal bool
// SMTP single-provider config (simple form). If SMTPProviders is set,
// that takes precedence.
SMTPHost string // GATEWAY_SMTP_HOST
SMTPPort int // GATEWAY_SMTP_PORT (default 587)
SMTPUser string // GATEWAY_SMTP_USER
SMTPPass string // GATEWAY_SMTP_PASS
SMTPFrom string // GATEWAY_SMTP_FROM
SMTPTLS bool // GATEWAY_SMTP_TLS (default true)
// SMTP multi-provider JSON. If set, parsed as []email.SMTPConfig and
// used as a chain in order. Overrides the single-provider env vars.
SMTPProviders string // GATEWAY_SMTP_PROVIDERS
// Public app URLs used in email links.
AppBaseURL string // GATEWAY_APP_BASE_URL — e.g. "https://app.example.com"
// How long an email-verification or password-reset token is valid for.
EmailTokenExpirySeconds int // GATEWAY_EMAIL_TOKEN_EXPIRY_SECONDS (default 86400)
// Postgres (alternate persistence driver). When PostgresDSN is set
// the application bootstrapper may prefer the Postgres-backed
// repository over EntDB; the actual driver selection lives in the
// internal/repo package.
//
// GATEWAY_POSTGRES_DSN e.g. "postgres://user:pass@host:5432/identity?sslmode=disable"
// GATEWAY_POSTGRES_MAX_CONNS pool size, default 25
// GATEWAY_POSTGRES_AUTO_MIGRATE run pending migrations on connect, default true
PostgresDSN string
PostgresMaxConns int
PostgresAutoMigrate bool
}
Config holds all identity service configuration.
func Load ¶
func Load() *Config
Load reads configuration from environment variables with GATEWAY_ prefix, falling back to sensible defaults for local development.
func (*Config) EmailServiceAddress ¶
EmailServiceAddress returns the host:port for the email service.
func (*Config) PasswordResetExpiry ¶
PasswordResetExpiry returns the password reset expiry as a time.Duration.
func (*Config) RefreshExpiry ¶
RefreshExpiry returns the refresh token expiry as a time.Duration.