v4: users sign in to one gerbeur instance with their account on another — topic instances, each with its own admins, domain and data, had no way to share accounts. Sign-in is federated over a subset of OpenID Connect, the authorization code flow with PKCE: each instance is an identity provider for its own users and a client for the others', and signs what it tells them with an Ed25519 key kept in federation_keys and published at /.well-known/jwks.json, beside its metadata at /.well-known/openid-configuration. Only sign-in is federated: an account from another instance is a local users row linked to (issuer, subject) in user_identities, with no password (password_hash ''), so sessions, roles, permissions, the socket and every foreign key work as before.
A remote user is name@host here, in users.username, in paths (/@alice@music.example) and in mentions, through one handle rule in shared/validation.ts that paths, MENTION_RE and Markdown all build on; Markdown undoes GFM's email autolink of a handle. Their name, email and avatar come from their home at each sign-in and by its signed events (federation_outbox, delivered by the federation job with backoff): a rename at home leaves the old handle an alias here, and a password change or a withdrawn grant ends their sessions here. Their password, email, avatar and name can't change here (assertLocalUser), nor can they sign in elsewhere from here. An admin keeps the trusted and blocked instances on /manage (federation:manage): a trusted instance's users sign in from a button on the login page, a blocked one's can't and are signed out at once, and any other's join with an invite from the register page. The /authorize page asks the user once per instance, and /settings lists the instances their account signs in to, each disconnectable; /login?next= brings a signed-out visitor back to /authorize. Emails stay unique among local accounts only, and migration 0024 adds the tables, makes that index partial and reserves authorize and federation as category slugs. remote/gerbeur-instance.ts is the only way to other instances: https and public addresses only, no redirects, no certificate fallback, unless GERBEUR_FEDERATION_ALLOW_PRIVATE lets two instances on one machine talk. 298 backend tests and 702 frontend tests pass, and deno check, deno fmt, deno lint, tsc, eslint, doc:lint and i18n:compile --strict are clean; checked end to end with two built instances on one machine: sign-in through the other's login and consent pages, consent skipped once granted and asked again after disconnecting, a rename and a password change at home reaching the other, and blocking; screenshots of the login, consent, profile, settings and manage pages at 1280 and 390px. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
37
README.md
37
README.md
@@ -60,6 +60,7 @@ variables:
|
||||
| `GERBEUR_EMAIL_LOCALE` | Language of every email: `en` or `fr` | `en` |
|
||||
| `GERBEUR_DEFAULT_STYLE` | The instance's style (`smooth`, `brutalist`, `geocities`, `nyt`, `kanagawa`, `melange`): the site's until one is picked, and the welcome and reset emails' | `smooth` |
|
||||
| `GERBEUR_WELCOME_EMAIL_BODY` | Markdown body for the account-creation welcome email; supports `{{username}}` and `{{site_name}}` | built-in template |
|
||||
| `GERBEUR_FEDERATION_ALLOW_PRIVATE` | `1` lets federated sign-in reach instances on private addresses and over http — for two instances on one machine, never in production | unset |
|
||||
| `GERBEUR_COMMUNITY_REFRESH_MINUTES` | How often, in minutes, the `/community` page's figures are recomputed | `15` |
|
||||
| `VITE_API_PROTOCOL` | API protocol baked into the frontend bundle (see [Production](#production)) | `http` |
|
||||
| `VITE_API_HOSTNAME` | API hostname baked into the frontend bundle | `localhost` |
|
||||
@@ -122,6 +123,28 @@ example.com {
|
||||
}
|
||||
```
|
||||
|
||||
### Several instances
|
||||
|
||||
Each instance is its own deployment, with its own database, uploads, admins and
|
||||
domain, but its users can sign in to the others with their account, and the
|
||||
other way round. A user from `music.example` is `@alice@music.example` on the
|
||||
instances they sign in to. Their password, email, avatar and name stay on their
|
||||
home instance, and the others follow its changes.
|
||||
|
||||
Every instance is ready for it: nothing to configure, as long as
|
||||
`GERBEUR_PUBLIC_URL` is the instance's https origin (no path) and the instances
|
||||
can reach each other. An admin decides who comes in, on `/manage`:
|
||||
|
||||
- users of a **trusted** instance sign in directly, from a button on the login
|
||||
page;
|
||||
- users of a **blocked** instance can't, and those already in are signed out;
|
||||
- users of **any other** instance join with an invite, from the register page,
|
||||
and sign in without one afterwards.
|
||||
|
||||
To try it on one machine, run two instances on different ports with
|
||||
`GERBEUR_FEDERATION_ALLOW_PRIVATE=1`, which lets them reach each other over
|
||||
plain http on localhost. Never set it in production.
|
||||
|
||||
## Project structure
|
||||
|
||||
```
|
||||
@@ -165,13 +188,13 @@ public/ # Static assets (favicon, manifest, service worker)
|
||||
|
||||
### URLs
|
||||
|
||||
Every page and API path follows one of two rules, which [API.md](API.md)
|
||||
states, along with every page, the slug and username rules and every
|
||||
endpoint. Pages are a hierarchy under `@name` for users and plain words for
|
||||
categories and app pages (`/@bob/dumps/never-gonna`, `/music/hot`), built and
|
||||
parsed by `shared/paths.ts`. API resources are `/api/<plural>/<key>`, the
|
||||
caller's own under `/api/me`. A route change updates its router's module doc
|
||||
and API.md together.
|
||||
Every page and API path follows one of two rules, which [API.md](API.md) states,
|
||||
along with every page, the slug and username rules and every endpoint. Pages are
|
||||
a hierarchy under `@name` for users and plain words for categories and app pages
|
||||
(`/@bob/dumps/never-gonna`, `/music/hot`), built and parsed by
|
||||
`shared/paths.ts`. API resources are `/api/<plural>/<key>`, the caller's own
|
||||
under `/api/me`. A route change updates its router's module doc and API.md
|
||||
together.
|
||||
|
||||
Whatever crosses the wire is defined once, in `shared/`: the API envelope
|
||||
(`shared/api.ts`), each domain's types and request bodies (`shared/dump.ts`,
|
||||
|
||||
Reference in New Issue
Block a user