Two servers can become friends. Federation is off by default; turning it
on makes an Ed25519 key pair, kept in the database and never returned.
- Admin routes: GET and PUT /federation (on or off, name, public address),
POST /federation/invites, POST /federation/friends (use an invite),
POST /federation/friends/{id}/approve and DELETE /federation/friends/{id}.
- POST /api/v1/peer/pair, the one route without a login: the code of an
invite is the proof. An invite works once and expires in 24 hours; only
a hash of its code is stored. At most 10 attempts a minute.
- The server that uses an invite checks that the key it gets back is the
one named in the invite. A friend is kept as incoming or outgoing until
both admins have agreed.
- https only, except plain http on a network of one's own (private,
loopback or link-local address, or a local name).
- A client of its own for friends, with no redirects, no proxy from the
environment, a size limit and a time limit; the providers' client stays
as it is.
- Migration 0023 for SQLite and PostgreSQL, OpenAPI paths and schemas,
contract test with two real servers.
- Admin > Federation in the web app, in English and Italian, and a
section in the README.
29 lines
1 KiB
SQL
29 lines
1 KiB
SQL
-- Federation between Sonda servers (see internal/federation). PostgreSQL flavour of sqlite/0023_federation.sql.
|
|
|
|
CREATE TABLE federation_settings (
|
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
enabled BOOLEAN NOT NULL DEFAULT FALSE,
|
|
name TEXT NOT NULL DEFAULT '',
|
|
address TEXT NOT NULL DEFAULT '',
|
|
public_key TEXT NOT NULL DEFAULT '',
|
|
private_key TEXT NOT NULL DEFAULT '',
|
|
updated_at BIGINT NOT NULL DEFAULT 0
|
|
);
|
|
|
|
CREATE TABLE federation_invites (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
code_hash TEXT NOT NULL UNIQUE,
|
|
created_at BIGINT NOT NULL,
|
|
expires_at BIGINT NOT NULL,
|
|
used_at BIGINT
|
|
);
|
|
|
|
CREATE TABLE federation_friends (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
address TEXT NOT NULL,
|
|
public_key TEXT NOT NULL UNIQUE,
|
|
state TEXT NOT NULL CHECK (state IN ('incoming', 'outgoing', 'active')),
|
|
created_at BIGINT NOT NULL,
|
|
approved_at BIGINT
|
|
);
|