Files
tern-server/.env.example
T
Mateusz PstruchaandClaude Opus 5.5 b718bc4c3a
CI / test (push) Successful in 6m31s
Add UnifiedPush delivery, device API and sliding sessions
New mail whose notify decision is true now wakes the user's registered
phones: a content-free {"kind":"sync"} payload, encrypted per RFC 8291
and VAPID-signed per RFC 8292 (key generated on first start, stored
encrypted with CREDENTIAL_KEY). Bursts coalesce into one push, and a
404/410 from the push server removes the device.

/api/devices registers, updates, lists and removes endpoints, and can
send a test push; GET /api/push returns the VAPID public key. For
self-hosted push servers, PUSH_URL_REWRITE maps the public endpoint
prefix to an internal one, and PUSH_CA_CERT / PUSH_TLS_INSECURE handle
private certificates.

Sessions now slide: each use extends expiry to the full TTL (at most
one write an hour), so a phone in regular use is never signed out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:46:33 +02:00

34 lines
1.5 KiB
Bash

# Copy to .env for local development (docker-compose reads this automatically
# for the `db` service password; the app reads it via dotenvy at startup).
DATABASE_URL=postgres://tern:tern@localhost:5432/tern
BIND_ADDR=127.0.0.1:8080
# 32 random bytes, base64-encoded. Generate with: openssl rand -base64 32
# Encrypts stored IMAP/SMTP credentials at rest (see src/crypto.rs). Losing
# this key makes every stored account credential unrecoverable — back it up
# outside the database.
CREDENTIAL_KEY=
BLOB_STORAGE_DIR=./data/blobs
# Sessions last this long since they were last *used* — a client in regular
# use stays signed in; one left alone for this long has to sign in again.
SESSION_TTL_HOURS=720
# Days mail stays in Trash before it's permanently deleted. 0 disables purging.
TRASH_RETENTION_DAYS=30
# --- UnifiedPush (Android notifications) ---
# Endpoints come from the phone's distributor (e.g. the ntfy app), so they
# carry the push server's *public* URL. If this server should reach it some
# other way, rewrite the prefix: comma-separated from=>to pairs.
#PUSH_URL_REWRITE=https://ntfy.example.org/=>http://ntfy:80/
# Trust an extra CA (PEM) for the push server, e.g. an internal CA...
#PUSH_CA_CERT=/etc/tern/push-ca.pem
# ...or, last resort, skip certificate checks for push requests entirely.
#PUSH_TLS_INSECURE=true
# Contact for push-service operators, sent in VAPID-signed requests.
#PUSH_VAPID_SUBJECT=mailto:you@example.org
RUST_LOG=tern_server=debug,tower_http=debug