Skip to content

About

Web admin panel for the Epistle mail server: domains, mailboxes, email security and queues on top of the mail API. Next.js.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

120 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

epistle-panel

Admin panel for the Epistle mail server: server status, domains, accounts, queues, deliveries and the suppression list on top of its management API.

CI

🚧 Early development. The status, accounts (create, delete and a detail page for each), domains, queue, deliveries and suppression views work, and the status view charts deliveries, the queue and the suppression list from them; the rest of the management API is not covered yet.

🧱 Stack

  • Next.js (App Router, TypeScript) + Tailwind CSS
  • next-intl: English, Spanish, Portuguese, French, German and Italian ship together; see docs/maintainers/i18n.md to add one
  • Typed Epistle API client with zod-validated responses; the bearer token stays server-side
  • Biome (lint + format), bun test

πŸ“¦ Install

The panel is meant to run only as a service of the stack that epistle generates. There is no standalone compose file. It ships in two forms, neither published yet: .github/workflows/release.yml builds both when a v* tag is pushed, and no release exists so far. See docs/maintainers/releasing.md.

  • Container image. ghcr.io/glyndor/epistle-panel, built from the Containerfile at the repository root. It runs as uid 65532 and listens on port 7587. The application runs here and nowhere else.
  • apt package. epistle-panel is a thin package with no Node runtime and no application code. It depends on epistle, podup and glyndor-archive-keyring and installs two files: /usr/share/glyndor/epistle-panel/image, naming the image tag that matches the package version, and /usr/share/glyndor/epistle-panel/README, saying what that file is for. The design is that epistle reads the image file to add the panel to its stack, but the epistle release that does so does not exist yet, so installing the package changes no running stack today; see debian/README.Debian. The package creates no account, no directory outside /usr/share and no secret.

TLS is not the panel's job: put your own proxy in front of it.

Reverse proxy requirements

The panel sets its own security headers (a Content-Security-Policy with a per-request nonce and frame-ancestors 'none', X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy), so the proxy in front of it has nothing to add and should not strip them. It does not set Strict-Transport-Security: that header belongs to the proxy that terminates TLS.

Your proxy must overwrite X-Forwarded-Host and X-Forwarded-Proto with the values it saw, never pass through what the client sent. Next derives the request's origin from them, and its Server Action origin check compares the Origin header against that same host. Set Host to the public name too, and send both headers on every request, for example in nginx:

proxy_set_header Host              $host;
proxy_set_header X-Forwarded-Host  $host;
proxy_set_header X-Forwarded-Proto $scheme;

scripts/headers/verify.sh (the port is PORT, default 7598) starts the built standalone server and asserts the headers, and that a hostile Host or X-Forwarded-Host never reaches the redirect's Location, against real HTTP. Run it after bun run build in internal/.

πŸš€ Development

cd internal
bun install
bun run dev

The dev server listens on http://localhost:3000. Point the panel at a running Epistle server with (EPISTLE_API_URL defaults to http://127.0.0.1:8025):

export EPISTLE_API_URL="http://127.0.0.1:8025"
export EPISTLE_API_TOKEN="<token>"
export EPISTLE_PANEL_SESSION_SECRET="<random 32+ byte secret>"
export EPISTLE_PANEL_ADMIN_ID="$(cat /proc/sys/kernel/random/uuid)"

Every account signs in on the same page, the root (/). The panel verifies the credentials against Epistle, which also says whether the account is an admin, and signs a session cookie with EPISTLE_PANEL_SESSION_SECRET; the role travels inside the signed token. After signing in everyone lands on /app/mail, the mail area (not built yet: the page says so). An admin finds there a link to the admin area. Without the session secret set, every page stays locked (fail-closed).

The admin area and its id

The administration lives at /app/{id}, where {id} is a UUID v4 that belongs to each installation, set with EPISTLE_PANEL_ADMIN_ID (a lower-case canonical UUID v4; uuidgen -r | tr A-Z a-z or cat /proc/sys/kernel/random/uuid make one).

  • Without a value the admin area is off. Every path under /app except /app/mail answers 404, and the start logs a warning. A value that is set but is not a lower-case UUID v4 stops the start with a message that names the variable and never the value.
  • It also has the _FILE form (EPISTLE_PANEL_ADMIN_ID_FILE) like the secrets below.
  • A request without a session, with a session that is not an admin's, or with another id gets the same 404 as a path that does not exist: no redirect, so nothing confirms that an admin area exists.
  • The id is not a secret. It is one more layer of obscurity, so a scanner finds nothing at /app/admin. The barrier is the session and the admin role, which every admin page and Server Action check again. The id appears only in links the panel builds for an admin session (the mail page's link and the admin pages themselves), never in a public page, robots.txt, a 404 or a log line.
  • The role is read from the signed token, so an account demoted in Epistle keeps the admin role until its session ends (at most 8 hours) or it signs out.
  • epistle generates the id and hands it to the panel when it renders the stack; a panel updated before that has no id, and so no admin area.

Secrets from files

EPISTLE_API_TOKEN, EPISTLE_PANEL_SESSION_SECRET and EPISTLE_PANEL_ADMIN_ID also have a _FILE form that points at a file holding the secret, which is how container secrets are mounted (for example under /run/secrets/):

export EPISTLE_API_TOKEN_FILE="/run/secrets/epistle_api_token"
export EPISTLE_PANEL_SESSION_SECRET_FILE="/run/secrets/epistle_panel_session_secret"
  • When both forms are set, the _FILE form wins.
  • Trailing whitespace, such as the final newline, is stripped from the file content.
  • A _FILE variable that is set but points at a missing, unreadable or empty file is an error. The panel never falls back to the plain variable in that case: a missing session secret locks every page and a missing API token fails every API call.
  • Error messages name the variable, never the path or the content.
  • The path must be absolute and name a regular file of at most 64 KiB; a symlink is refused. The value is read once per process, so rotate a secret by restarting the service.

API address

EPISTLE_API_URL must be a bare http or https origin: no credentials, path, query or fragment. Link-local and metadata addresses (169.254.0.0/16, fe80::/10) are refused. Plain http is accepted for a loopback host only; for another host use https, or list the host in EPISTLE_API_ALLOW_HTTP_HOSTS (comma separated) when the link is already private, for example over WireGuard. An invalid value makes every API call fail without sending a request.

Branding and theme

The image is immutable, so the look is set from the environment and from files mounted into the container. See docs/maintainers/customising.md for what each one can change and what needs a rebuild.

Variable Effect
EPISTLE_PANEL_THEME_CSS_FILE Absolute path of a stylesheet served at /theme.css and linked after the panel's own. Redefine the CSS variables of theme.css in it. At most 128 KiB, a regular file, no symlink. Read on every request.
EPISTLE_PANEL_BRAND_NAME Product name in the sidebar, the sign-in page and the tab title. 1 to 40 characters; an invalid value falls back to Epistle.
EPISTLE_PANEL_BRAND_LOGO_FILE Absolute path of a PNG, JPEG, WebP, ICO or SVG (at most 256 KiB) served at /brand/logo. An SVG with script is refused.
EPISTLE_PANEL_BRAND_FAVICON_FILE The same, served at /brand/favicon and used as the tab icon.

The original copyright notice stays in the interface whatever is set. A file that cannot be used is answered with a 404 and one log line that names the variable, never the path.

Sign-in CAPTCHA (optional, off by default)

Variable Effect
EPISTLE_PANEL_CAPTCHA_PROVIDER turnstile, recaptcha, hcaptcha or custom. Unset or off loads nothing from another host.
EPISTLE_PANEL_CAPTCHA_SITE_KEY The public site key.
EPISTLE_PANEL_CAPTCHA_SECRET_KEY_FILE Absolute path of the secret key (or EPISTLE_PANEL_CAPTCHA_SECRET_KEY), read like the other secrets.
EPISTLE_PANEL_CAPTCHA_HOSTNAME Optional host name the provider must report.
EPISTLE_PANEL_CAPTCHA_SCRIPT_URL, EPISTLE_PANEL_CAPTCHA_VERIFY_URL, EPISTLE_PANEL_CAPTCHA_RESPONSE_FIELD For custom only.

When it is on, the sign-in page's Content-Security-Policy gains the provider's hosts and no other page does. A provider named without a complete setup refuses every sign-in, with a log line that names the variable. The provider calls are capped (16 at once, a short bounded line behind them); sustained load above that cap refuses sign-ins, the same trade-off as the API-call cap. See docs/maintainers/forms.md.

Sessions and sign-in limits

  • The session cookie is named __Host-epistle_session and is always Secure, HttpOnly, SameSite=Lax, Path=/ with no Domain. The __Host- prefix requires Secure, so the cookie does not depend on NODE_ENV. Serve the panel over HTTPS, normally terminated by your reverse proxy. Chrome and Firefox are documented as accepting it on http://localhost, which keeps bun run dev working; over plain HTTP on any other host the browser drops the cookie and sign-in does not stick. Only Chromium was checked here (see docs/maintainers/e2e.md); Safari and Firefox were not.
  • Sessions last 8 hours. Signing out revokes the token on the server, not only in the browser. The revocation list lives in the memory of one panel process: it is lost on restart and not shared between replicas, so run a single instance. After a restart a token revoked earlier is accepted again until it expires. The list holds at most 10,000 entries; past that, the entry that expires first is dropped, so the revocations with the most life left are the last to go. Reaching the cap takes 10,000 sign-outs inside one session lifetime, after which a dropped token verifies again until it expires.
  • Sign-in attempts are limited in memory, per process, before the API is called, and the limiter does not read forwarded client-address headers. The Epistle API has its own failed-authentication limiter, which currently sees one address for all panel traffic; forwarding the admin's address to it is a separate change in Epistle. Three limits apply:
    • Per account name, in chains. Three free tries, then a lock that doubles (2 seconds and up). A chain starts with the first attempt and lasts 15 minutes: no lock ends later than the chain, a lock is never renewed, and afterwards the name starts from a clean count. The right password is refused while a lock holds, and the lock ends. About a dozen attempts per name pass in each chain.
    • Globally, 60 failed attempts per minute across all names. Only failures count. Once the ceiling is hit, names that signed in during this process in the last 8 hours still get through, subject to their own lock.
    • At most 8 attempts wait on the API at once, for every name. What an attacker can still do: keep 60 failing attempts per minute going to refuse every name that has not signed in during this process, for example the first sign-in after a restart, for as long as the flood lasts; fail one name enough times to lock it for the rest of its chain (up to 15 minutes); and, by sending a request the moment a name's chain restarts, keep that name locked across chains. A limiter keyed by name cannot rule that last case out; closing it takes a second factor or a client address from a trusted proxy.
  • Every sign-in takes at least one second, whatever the outcome, so an unknown account, a wrong password and a success look alike by time. That only holds while the API answers within the floor, and the real API's password hash time was not measured. Set EPISTLE_PANEL_LOGIN_MIN_MS (whole milliseconds, 0 to 30000) to raise or lower it; a value that does not parse, or one above 30000, keeps the default.
  • A render error shows the panel's own error page (translated, no inline styles), not Next's built-in one, which the Content Security Policy would leave unstyled.

Contributing

Branch from develop and open the pull request against develop. The Next.js project lives in internal/, so every command runs from there:

cd internal
bun run lint
bun run typecheck
bun test
bun run build

The Debian package has its own checks, run by the Debian package workflow: scripts/debian/build.sh <output-dir> builds and lints the .deb in a Debian container, and scripts/debian/smoke.sh <path-to-.deb> installs it there. Both need podman or docker. BUILD_IMAGE and SMOKE_IMAGE replace the Debian image they use, docker.io/library/debian:trixie by default.

scripts/e2e/run.sh checks the built server against a stand-in API (see docs/maintainers/e2e.md); the End-to-end workflow runs it, and scripts/headers/verify.sh, on pull requests that touch the code it exercises.

The fifteen workflows split by when they run. CI (lint, typecheck, build, the unit tests with the coverage threshold, and the dependabot freshness check) runs on every push to main or develop and on every pull request into develop. Others run only when their answer can change: Container (the image inputs), Debian package (the package inputs), Dependency audit (lockfile or manifest, plus weekly), actionlint (workflow files), Bun version (one Bun release across the workflows and the Containerfile), Pin policy (workflow files, plus weekly), Randomized tests (the unit suite in random order with a fixed seed, when internal/ sources or its test config change), Release scripts (the tag check, image tags, signing and publishing scripts under scripts/release) and Dependabot security watch. All of these, and Line limit (when a source file changes), run on pull requests into develop only: the promotion pull request into main carries a tree they already checked. DCO runs on every pull request into main or develop, and guard on every pull request into main. Release runs on a v* tag.

License

MIT

About

Web admin panel for the Epistle mail server: domains, mailboxes, email security and queues on top of the mail API. Next.js.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages