Skip to main content

Module config

Module config 

Source
Expand description

Layered TOML configuration (slice 8.3).

Settings::load("local") reads, in order:

  1. config/default.toml — committed defaults shared by every env.
  2. config/{env}.toml — env-specific overrides (local, staging, prod, …). Missing file is fine — the load skips it.
  3. Environment variables — anything matching RUSTANGO__SECTION__KEY overrides 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§

AdminSettings
Auto-admin tweaks read at boot. Mirrors the admin::Builder flags so Settings-driven projects don’t need to hand-wire them.
AuditSettings
Audit-log retention + redaction policy (#87).
AuthSettings
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.
BrandSettings
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 the Org row.
CacheSettings
Cache-backend selection. Slice 10.3 lights up; the section is in v0.8 so config files written today survive the v0.10 upgrade.
DatabaseSettings
Connection URL + pool sizing for the primary database.
I18nSettings
[i18n] — Django-shape LANGUAGE_CODE / LANGUAGES / LOCALE_PATHS settings (#403). Used by crate::i18n::Translator::from_settings to bootstrap a Translator directly from TOML so deployments don’t have to hard-code locale wiring in src/main.rs.
JobsSettings
Background-jobs runner config. Slice 10.1 lights up.
JwtSettings
JWT lifetime knobs (#87). Defaults match rustango::tenancy::auth_routes::Config::default().
LoggingSettings
Tracing-subscriber config — level + format + optional rolling file sink (roadmap #8, v0.30.11). Drives crate::logging::Setup::from_settings which is the same builder users construct manually for ad-hoc setups; installing via Settings + crate::manage::Cli::with_logging just removes the boilerplate.
MailSettings
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.
RoutesSettings
URL-prefix overrides for the framework’s built-in routes (#87, mirrors tenancy::RouteConfig from #74). Declaring these in TOML lets ops change the admin path without touching code.
SecuritySettings
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).
ServerSettings
HTTP server bind + request-timeout knobs (#87).
Settings
Top-level config — every section is optional and defaults to its type’s Default impl. The loader fills sections from config/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-sso feature). Read at boot by the admin Builder; the verified IdP email must match an existing admin user — SSO authenticates but never auto-provisions. Multi-tenant apps configure SSO per-Org instead of here.
TenancySettings
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§

ConfigError
Errors the layered loader can raise.