Expand description
Layered TOML configuration (slice 8.3).
Settings::load("local") reads, in order:
config/default.toml— committed defaults shared by every env.config/{env}.toml— env-specific overrides (local,staging,prod, …). Missing file is fine — the load skips it.- Environment variables — anything matching
RUSTANGO__SECTION__KEYoverrides the corresponding nested TOML key. Double-underscore is the path separator.RUSTANGO__DATABASE__URL=postgres://…overrides[database] url = "…".
The pipeline returns a typed Settings struct with sections
for database, secret_key, admin, tenancy, cache, jobs,
mail. Unknown keys in the TOML are ignored (forward-compat).
§Example
ⓘ
// config/default.toml
// [database]
// url = "postgres://localhost/myapp_dev"
//
// [admin]
// read_only_tables = ["audit_log"]
// config/prod.toml
// [database]
// pool_max_size = 50
// RUSTANGO__DATABASE__URL=postgres://…/myapp_prod cargo run
let cfg = rustango::config::Settings::load("prod")?;
assert_eq!(cfg.database.pool_max_size, 50);Gated by the config feature (in default). Drop with
default-features = false if you want a bare ORM dep without
toml pulled in.
Structs§
- Admin
Settings - Auto-admin tweaks read at boot. Mirrors the
admin::Builderflags soSettings-driven projects don’t need to hand-wire them. - Audit
Settings - Audit-log retention + redaction policy (#87).
- Auth
Settings - Authentication knobs (#87) — JWT lifetimes, password hashing cost, account lockout policy. Each field has a sensible default matching the framework’s hardcoded values, so existing deployments don’t behave differently after upgrading.
- Brand
Settings - Operator console + tenant admin display strings (#87, mirrors
#72). The framework today reads these via
RUSTANGO_OPERATOR_*env vars; declaring them in TOML makes per-tier branding (different staging vs prod logo) cleaner. Per-tenant branding stays on theOrgrow. - Cache
Settings - Cache-backend selection. Slice 10.3 lights up; the section is in v0.8 so config files written today survive the v0.10 upgrade.
- Database
Settings - Connection URL + pool sizing for the primary database.
- I18n
Settings [i18n]— Django-shapeLANGUAGE_CODE/LANGUAGES/LOCALE_PATHSsettings (#403). Used bycrate::i18n::Translator::from_settingsto bootstrap aTranslatordirectly from TOML so deployments don’t have to hard-code locale wiring insrc/main.rs.- Jobs
Settings - Background-jobs runner config. Slice 10.1 lights up.
- JwtSettings
- JWT lifetime knobs (#87). Defaults match
rustango::tenancy::auth_routes::Config::default(). - Logging
Settings - Tracing-subscriber config — level + format + optional rolling
file sink (roadmap #8, v0.30.11). Drives
crate::logging::Setup::from_settingswhich is the same builder users construct manually for ad-hoc setups; installing via Settings +crate::manage::Cli::with_loggingjust removes the boilerplate. - Mail
Settings - Mailer config. Slice 10.2 lights up.
- McpSettings
[mcp]— Model Context Protocol server configuration (epic #1013). All fields are optional; accessors supply the framework defaults.- Routes
Settings - URL-prefix overrides for the framework’s built-in routes (#87,
mirrors
tenancy::RouteConfigfrom #74). Declaring these in TOML lets ops change the admin path without touching code. - Security
Settings - Security-headers + CSP + CORS knobs (#87). The defaults map
straight to
SecurityHeadersLayer::strict(); per-section overrides let staging/dev relax specific constraints (e.g. allow inline scripts during local development). - Server
Settings - HTTP server bind + request-timeout knobs (#87).
- Settings
- Top-level config — every section is optional and defaults to its
type’s
Defaultimpl. The loader fills sections fromconfig/default.toml+config/{env}_settings.toml(or the legacy{env}.toml) +RUSTANGO__*env-var overrides. - SsoSettings
- Global SSO (OpenID Connect / social OAuth) for the admin login on a
non-tenanted app (
admin-ssofeature). Read at boot by the adminBuilder; the verified IdP email must match an existing admin user — SSO authenticates but never auto-provisions. Multi-tenant apps configure SSO per-Orginstead of here. - Tenancy
Settings - Multi-tenancy operator-side settings. Tenant-side resolver config is per-Org row in the registry; this section is for the host-wide knobs.
Enums§
- Config
Error - Errors the layered loader can raise.