Skip to main content

Configuration

Configuration is environment variables only — there is no config file. The canonical list, with the reasoning, is .env.example in the repo, which names every variable and the code that reads it; this page is the same set arranged for looking things up.

Required — Ward will not start without these​

WARD_SIGNING_KEY_PATH
The Ed25519 private key. Mode 0600, generated once on the server and never by a deploy.
WARD_ADMIN_USERNAME
The break-glass superuser's name.
WARD_ADMIN_PASSWORD
Its password. openssl rand -base64 32.
WARD_PUBLIC_ORIGIN
Scheme + host, no path, no trailing slash. Becomes the iss claim.

Refusing to boot without the admin credential is deliberate: it is the only credential that still works when the database is empty or has lost its last admin, so a service that started without one could be locked out of itself.

All variables​

VariableRead byNotes
PORTthe listenerBound on 127.0.0.1 only. Caddy is the sole way in.
WARD_TRUSTED_PROXIESthe login lockoutOptional; unset trusts loopback only. Required in practice in a container. See Trusted proxies.
WARD_DB_PATHthe connectionThe only copy of who anybody is. See the WAL warning below.
WARD_SIGNING_KEY_PATHkey loadingRequired.
WARD_ADMIN_USERNAMEconsole sessionRequired.
WARD_ADMIN_PASSWORDconsole sessionRequired.
WARD_PUBLIC_ORIGINtoken minting (iss), UI redirectsRequired.
WARD_MAIL_TRANSPORTapi/src/mail/file or smtp.
WARD_MAIL_FILE_DIRfile transportRequired when transport is file.
WARD_MAIL_FROMboth transportsRequired in both modes.
WARD_SMTP_HOSTsmtp transportRequired when transport is smtp.
WARD_SMTP_PORTsmtp transport
WARD_SMTP_USERsmtp transport
WARD_SMTP_PASSWORDsmtp transport
WARD_OIDC_ISSUERapi/src/oidc/Optional; unset, the OpenID Connect provider is off. The issuer as the browser sees it, ending in /oidc. See Sign in with Ward.
WARD_UI_URLapi/src/oidc/Required with the issuer. Ward's UI on the same origin.

Trusted proxies​

The login lockout counts failures per client address, and Ward only learns that address from Caddy's X-Forwarded-For. It believes the header only when the socket peer is a proxy it trusts, and then reads only the last element, the one Caddy appended. Anything a client wrote earlier in the header is never read.

Loopback is always trusted. WARD_TRUSTED_PROXIES adds more: comma-separated addresses or CIDR ranges, IPv4 or IPv6. An IPv4-mapped peer (::ffff:172.19.0.3) matches an IPv4 range.

Set it whenever Ward runs in a container

Host Caddy reaches a container through Docker's proxy, so the peer Ward sees is a Docker bridge address, never loopback. With nothing listed, every request keys on that one address, and five bad passwords from anyone lock everyone out of /login for 15 minutes. Use Docker's default 172.16.0.0/12 unless the stack pins a subnet, and confirm it on the host with docker network inspect <network> --format '{{range .IPAM.Config}}{{.Subnet}}{{end}}'.

A malformed entry, host bits set past the prefix (172.19.0.3/16), or a /0 stops the boot and names the entry. Two misconfigurations are logged as throttled warnings: a trusted peer that forwarded no address, and an X-Forwarded-For from an untrusted peer, which is what a proxy missing from the list looks like.

Apps on the shared library set AUTH_TRUSTED_PROXIES the same way.

The signing key​

One Ed25519 private key signs Ward's own access tokens and every ID token the OpenID Connect provider issues to an app.

  • Not in the repo, and not in .env. .gitignore excludes *.pem, *.key and api/data/ — belt and braces, because a single git add -A committing it means rotating estate-wide and scrubbing history.
  • Created once on the server, backed up, and never regenerated by a deploy. A new key signs the whole estate out at once and reads as an outage rather than as a rotation.
  • Apps only ever see the public half, over the provider's /oidc/jwks (the same key as /.well-known/jwks.json).

The database​

WARD_DB_PATH holds accounts, credentials, sessions and grants.

Back up all three files, never ward.db alone

WAL mode means committed data lives in the -wal sidecar until a checkpoint. Copying ward.db on its own can produce a file that is missing recent commits while looking entirely valid. See Data model.

Mail​

file writes each message to WARD_MAIL_FILE_DIR instead of sending, so the registration and verification flow is exercisable locally with no SMTP server.

The directory is gitignored, and that is a security measure rather than tidiness: a verification mail holds a single-use token, so those files are credentials on disk, not logs.

What the deploy sets for each app​

An app is configured as an OpenID Connect client of Ward, not with any Ward secret. vps-deploy writes the same set into every app that signs in through Ward:

VariableValue
WARD_OIDC_ISSUERWard's external issuer, ending in /oidc
WARD_OIDC_CLIENT_IDthe app's slug at Ward
WARD_OIDC_CLIENT_KEYthe app's private JWK, from its own secrets/<app>.env
WARD_OIDC_REDIRECT_URIthe app's callback
WARD_OIDC_POST_LOGOUT_REDIRECT_URIwhere "sign out of Ward too" returns
AUTH_TRUSTED_PROXIESthe same list Ward's own lockout trusts

plus the app's own public origin. Reading Ward's identity in the deploy repo registers the deploy-order edge as a side effect, so an app cannot be configured as a client without also being ordered after Ward. A missing client key is named by preflight against the right file, rather than surfacing as a failed sign-in after a green deploy.

The variables of the retired cookie contract (WARD_APP_KEY, WARD_API_BASE_PATH, and an app-side WARD_PUBLIC_ORIGIN) are no longer written or read; an app's env file that still carries them can drop them.

See Sign in with Ward and the shared library's adoption guide (shared-library/README.md in the repo) for what an app does with them.