recourse
A small axum web application scaffold with:
- axum web stack with
minijinjatemplates (embedded at build time, hot-reloaded fromtemplates/in dev) - sea-orm + Postgres with a
migrationcrate (auto-migrates on boot) - Auth: Argon2 password hashing, cookie sessions, invite-only registration, email verification (mail through mail-prism), optional “Sign in with NEIAM” (OIDC), and bearer API tokens for scripts/mobile
- Tailwind + DaisyUI front-end with a theme switcher (
just assetsto build) - Prometheus metrics at
/metrics, health check at/healthz - A
Dockerfile(assets → cargo → debian-slim) andcompose.yml(Postgres + web)
Quick start
just deps # npm install (frontend deps)
just assets # build CSS + JS + webfonts
just db-up # start Postgres via podman compose
just migrate # apply migrations
just admin alice alice@example.com # first (staff) account; prints its password
just serve # run the web service on :3000
Sign in with the printed password. Further members join through invites
(just invite, or the Invites page), or are created the same way.
Staff
Staff (category/reaction admin, moderation) is only ever granted on purpose:
manage user create … --staff, or manage user set-staff <name> for an
existing account. Registering — even as the very first account — never makes
anyone staff.
Configuration (environment)
| Var | Default | Meaning |
|---|---|---|
APP_NAME |
recourse |
Display name in templates |
DATABASE_URL |
postgres://recourse_user:recourse_password@localhost:5439/recourse |
Postgres connection |
BIND_ADDRESS |
0.0.0.0:3000 |
Listen address |
SESSION_DURATION_HOURS |
24 |
Cookie session lifetime |
REGISTRATION_TOKEN_DURATION_DAYS |
7 |
Default invite validity |
AUTO_MIGRATE |
true |
Run migrations on boot |
REGISTRATION_ENABLED |
false |
Allow /register without an invite link (token still required) |
PUBLIC_URL |
http://localhost:<BIND port> |
Public origin: base of email-verification links, the default OIDC redirect URI and the API-token curl example. https:// also marks the session cookie Secure |
MIN_TRUST_TO_CREATE_TAG |
3 |
Trust level needed to mint new tags |
MAIL_PRISM_URL / MAIL_PRISM_API_KEY |
(unset) | Send mail through mail-prism. Unset (or blank): mail is only logged |
MAIL_FROM_ADDRESS |
(the key’s application address) | Must equal the mail-prism application address if set |
MAIL_FROM_NAME |
APP_NAME |
From display name |
EMAIL_VERIFICATION_TTL_HOURS |
48 |
Lifetime of a verification link |
REQUIRE_EMAIL_VERIFICATION |
true |
Unverified accounts can read but not post/reply/react/bookmark/tag |
OIDC_ENABLED, OIDC_LOGIN_MODE, OIDC_* |
off | “Sign in with NEIAM”; see below and the neiam-auth README |
OIDC_PASSWORD_LOGIN |
true |
false hides and refuses password login (implied by OIDC_LOGIN_MODE=sso_strict) |
Email verification
New accounts (registration through an invite) start unverified: they can
read everything but can’t post, reply, react, bookmark or create tags until
they follow the link mailed to them. A banner says so, with a “Resend link”
button (also on the profile; at most one link per 10 minutes). Links are
single-use, expire after EMAIL_VERIFICATION_TTL_HOURS, and a new one replaces
the previous one; only a SHA-256 of each token is stored. Accounts that existed
before verification was added were marked verified by the migration; accounts
made with manage user create start verified, as do accounts signing in through
an OIDC provider with OIDC_TRUST_EMAIL=true that vouches for the address.
Mail goes through mail-prism when
MAIL_PRISM_URL and MAIL_PRISM_API_KEY are set. The templates live in this
repo under mail_prism/ and the webservice pushes them
to mail-prism on startup (PUT /api/v1/templates); each verification mail
carries an idempotency_key per token, so a retry never sends twice. The
client crate is vendored in crates/mail-prism-client (the mail-prism repo is
private; see its VENDORED.md).
Without mail-prism (development) the app runs normally and writes each
message, link included, to its log at INFO
(outbound mail (log transport …)). manage user verify-email <name> skips
the link; manage user resend-verification <name> prints a fresh one;
manage email test <to> checks the mail-prism setup.
Sign in with NEIAM
neiam-auth v0.4.0 (git dependency,
pinned to the tag, sea-orm feature for sea-orm 1.1), wired as in the
neiam-htmx template. Off by default: until OIDC_ENABLED=true there is no
button and /auth/oidc/* returns 404 (except /auth/oidc/health). The
oidc_identities migration always runs.
OIDC_ENABLED=true
OIDC_LOGIN_MODE=mixed # local | mixed (default) | sso | sso_strict
OIDC_ISSUER=https://auth.neiam.org
OIDC_CLIENT_ID=recourse
OIDC_CLIENT_SECRET=... # or OIDC_CLIENT_SECRET_FILE
OIDC_REDIRECT_URI=https://<host>/auth/oidc/neiam/callback # default: ${PUBLIC_URL}/auth/oidc/neiam/callback
OIDC_SCOPES="openid profile email groups"
OIDC_GROUPS_CLAIM=groups
OIDC_TRUST_EMAIL=true # LDAP mail is admin-set
OIDC_LABEL="Sign in with NEIAM"
OIDC_LOGOUT_URL=https://auth.neiam.org/logout
# OIDC_PROVISION=invite_only # default; `auto` creates accounts on first login
# OIDC_PROVISION_GROUPS=forum # invite_only, but members of these groups get an account
Linking (src/auth/oidc.rs): an existing (iss, sub) link; “Link NEIAM
account” on the profile; a single active account with the same verified email
(with OIDC_TRUST_EMAIL); or a new, passwordless account — only through an
invite (/register?token=… shows “Sign up with NEIAM”; in sso_strict the
invite link goes straight there) or PROVISION=auto / PROVISION_GROUPS,
keeping registration invite-only by default. A taken username or email is
never taken over, and accounts created this way are never staff. In
sso_strict, password login and local registration are refused.
Binaries
recourse— the web servicemanage— admin CLI:manage user create <name> --email E [--staff] [--password-stdin]— no invite needed; without--password-stdina strong password is generated and printed oncemanage user list | set-staff <name> [--revoke] | set-trust <name> <0-4> | activate <name> | deactivate <name> | delete <name> --yesmanage user verify-email <name> | resend-verification <name>manage invite create [--email E] [--days N] | list | show <token>manage email test <to>— send a test message through mail-prism (or report it isn’t configured)- Justfile shortcuts:
just manage …,just admin <name> <email>,just invite [days],just staff <name>,just trust <name> <level>