Files
Warp/warp.yaml.example
T
tajniak81andClaude Opus 5 6004bb01de
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
Phase 1: accounts and sessions
Implements PLAN.md Phase 1. A client can now register, log in, manage its
devices and set its profile; an operator can create accounts and flip the
runtime switches. There are still no rooms and no real /sync.

userapi: accounts, argon2id passwords in PHC format, devices, access and
refresh tokens stored as SHA-256 hashes, account data and the admin flag.
Its storage interface is storage.UserStore, implemented once in sqlstore
with `?` placeholders; the postgres driver supplies a rebind function and
unique-violation recognition rather than keeping a second copy of thirty
statements. Timestamps in these tables are int64 milliseconds, the unit the
Client-Server API uses on the wire.

Client-Server API: register (user-interactive auth with m.login.dummy and
optional registration tokens), register/available, token validity, login
with m.login.password, logout, logout/all, refresh, account/whoami,
capabilities, devices/* with password-gated deletion, profile/*, global and
per-room account data.

GET /sync is a deliberate placeholder: it answers a valid token with an
empty but well-formed response and refuses a revoked one. Phase 1 has no
rooms, so that is the whole truth, and it is what makes session revocation
observable. Phase 4 replaces it with the syncapi.

Auth middleware resolves a bearer token (header or the legacy query
parameter) to a device and user, answering an expired token with the soft
logout the spec asks for. Rate limiting is a token bucket per endpoint class
keyed on the client address, returning M_LIMIT_EXCEEDED with retry_after_ms.

adminapi v1 under /_warp/admin/v1: admin-only auth via a normal Matrix
token, GET/PUT /federation and /registration driving internal/settings and
reporting a config-pinned switch as a 409, GET/POST /users, GET /stats.

warp create-account [--admin] creates the first account straight in the
database, so a new install with registration off has a way in.

Complement is wired up for the federation=off profile: an image meeting its
contract, an entrypoint that configures Warp entirely from WARP_*
variables, and a runner that builds, clones and executes the target set
(TestRegistration, TestLogin, TestDeviceManagement). It has not been run
yet -- there is no container runtime on the development machine -- so the
three tests' assertions were read from the Complement sources and pinned as
httptest tests instead, and CI gained a job that runs the real thing.

Also fixes a .gitignore bug from Phase 0: the unanchored `warp` pattern,
meant for the built binary, also matched the directory server/cmd/warp and
silently excluded the entire command package from the repository. The
binary patterns are now anchored to the repository root, and cmd/warp is
committed for the first time.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-15 18:18:37 +02:00

141 lines
5.7 KiB
Plaintext

# Warp homeserver configuration.
#
# Copy to warp.yaml and edit. Every field below is optional except
# global.server_name; the values shown are the defaults.
#
# Any field can also be set from the environment, which wins over this
# file. The variable name is on the right of each line below, e.g.
# WARP_SERVER_NAME=warp.example WARP_FEDERATION_ENABLED=true warp serve
# List values are comma-separated; a single "-" clears a list.
version: 1
global:
# The Matrix server name. It appears in every user, room and event ID
# and CANNOT be changed after the first event is written. WARP_SERVER_NAME
server_name: warp.example
# ed25519 signing key, created by `warp generate-keys`. WARP_PRIVATE_KEY
private_key: ./keys/signing.key
well_known:
# Advertised to clients as m.homeserver.base_url.
# Defaults to https://<server_name>. WARP_WELL_KNOWN_CLIENT_BASE_URL
client_base_url: ""
# Optional identity server. WARP_WELL_KNOWN_IDENTITY_SERVER_BASE_URL
identity_server_base_url: ""
# Advertised to other homeservers as m.server, e.g. "warp.example:8448".
# Only served while federation is enabled; empty means other servers
# fall back to SRV/A resolution. WARP_WELL_KNOWN_SERVER_ADDRESS
server_address: ""
listen:
address: ":8008" # WARP_LISTEN_ADDRESS
read_header_timeout: 10s # WARP_READ_HEADER_TIMEOUT
read_timeout: 60s # WARP_READ_TIMEOUT
write_timeout: 120s # WARP_WRITE_TIMEOUT
idle_timeout: 120s # WARP_IDLE_TIMEOUT
max_header_bytes: 1048576 # WARP_MAX_HEADER_BYTES
shutdown_timeout: 30s # WARP_SHUTDOWN_TIMEOUT
database:
# sqlite (dev, single user), postgres (production) or pocketbase
# (appliance; not implemented yet). WARP_DB_DRIVER
driver: sqlite
# sqlite: file:warp.db?_pragma=journal_mode(WAL)
# postgres: postgres://warp:secret@localhost/warp?sslmode=disable
# WARP_DB_CONNECTION_STRING
connection_string: "file:warp.db?_pragma=journal_mode(WAL)&_pragma=busy_timeout(10000)&_pragma=foreign_keys(1)"
max_open_conns: 10 # WARP_DB_MAX_OPEN_CONNS (ignored by sqlite:
max_idle_conns: 5 # WARP_DB_MAX_IDLE_CONNS one writer only)
conn_max_lifetime: 1h # WARP_DB_CONN_MAX_LIFETIME
# Apply pending migrations on startup. Set false to gate schema changes
# behind an explicit `warp migrate`. WARP_DB_AUTO_MIGRATE
auto_migrate: true
client_api:
# The Matrix spec expects a homeserver to allow any origin. Narrow this
# if only your own web client talks to it. WARP_CORS_ALLOWED_ORIGINS
cors_allowed_origins: ["*"]
# Take the client address from X-Forwarded-For instead of the socket.
# Turn this on ONLY behind a reverse proxy that overwrites the header:
# anyone can send it, and the rate limiter keys on the result.
# WARP_TRUST_X_FORWARDED_FOR
trust_x_forwarded_for: false
# Expire access tokens after this long. 0 (the default) issues tokens
# that never expire, which is what clients without refresh-token
# support need. With a lifetime set, clients that ask for
# refresh_token on login get one. WARP_ACCESS_TOKEN_LIFETIME
access_token_lifetime: 0s
# How long a refresh token may be exchanged for a new access token.
# 0 means no expiry. WARP_REFRESH_TOKEN_LIFETIME
refresh_token_lifetime: 0s
# Per-endpoint rate limiting. Each bucket allows `burst` requests back
# to back and returns one slot every `interval`, per client address.
# Login and registration get their own, tighter, buckets because they
# are the two endpoints worth brute-forcing.
#
# Only `enabled` has an environment override (the three buckets share a
# type, so per-bucket variables would collide): set
# WARP_RATE_LIMIT_ENABLED=false to turn the whole thing off, which is
# what a test harness such as Complement wants.
rate_limit:
enabled: true # WARP_RATE_LIMIT_ENABLED
default:
burst: 30
interval: 100ms
login:
burst: 10
interval: 1s
register:
burst: 5
interval: 2s
federation:
# Off by default: a new install is a private homeserver until you say
# otherwise. WARP_FEDERATION_ENABLED
enabled: false
# Non-empty = federate ONLY with these servers.
# WARP_FEDERATION_ALLOWLIST
allowlist: []
# Always blocked, even if listed above. WARP_FEDERATION_DENYLIST
denylist: []
# Let the admin API flip `enabled` without a restart. When true, the
# stored setting overrides the value above on boot.
# WARP_FEDERATION_ALLOW_RUNTIME_TOGGLE
allow_runtime_toggle: true
registration:
# Off by default. Make the first account with
# `warp create-account --username you --admin`, then turn registration
# on from the admin API if you want others to sign up.
enabled: false # WARP_REGISTRATION_ENABLED
allow_runtime_toggle: true # WARP_REGISTRATION_ALLOW_RUNTIME_TOGGLE
# Non-empty = registration also requires one of these tokens, as the
# m.login.registration_token stage of the sign-up flow. Per-token use
# counts and expiry arrive with admin token management in Phase 9.
# WARP_REGISTRATION_TOKENS
tokens: []
logging:
level: info # debug, info, warn, error WARP_LOG_LEVEL
format: text # text or json WARP_LOG_FORMAT
add_source: false # WARP_LOG_ADD_SOURCE
metrics:
enabled: true # WARP_METRICS_ENABLED
path: /metrics # WARP_METRICS_PATH