Document fediverse sharing; mark phase 1 done (phase 1, step 9)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 1m7s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s

README: what sharing does today, how an operator enables it (settings,
UI forwarding, HTTPS), and the permanence of handles and the key
secret. Federation README: key secret, forwarded paths and module
layout. The phase 1 plan is marked done, with the real-Mastodon check
still outstanding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 20:37:30 +01:00
1 parent 913ef67aca
commit 6b09e041b8
3 files changed
+41

No files matched your search

+18
View File
@@ -92,6 +92,24 @@ Imports run in the background in the `worker` service. The page shows progress,
Unlike live scrobbles, imports keep plays of any age. They still skip rows with no artist or track, and plays dated in the future. Plays already in your history are skipped, so importing again is safe.
## Sharing on the fediverse (in development)
Users can make their profile findable from Mastodon and other fediverse apps as `@name@<your UI host>`. Following, and posts (weekly summaries, milestones, now playing), are still being built; see `docs/design/activitypub.md`. Until then, profiles advertise follower approval, so a follow waits as a request rather than failing.
It's **off unless the server enables it**, and then **off for each user** until they switch it on under **Sharing**. To enable it:
1. Set these on the API and worker:
- `FEDERATION_ENABLED=1`
- `FEDERATION_DOMAIN`: the UI's host, e.g. `scrobble.example`
- `FEDERATION_BASE_URL`: the UI's origin, e.g. `https://scrobble.example`
- `FEDERATION_KEY_SECRET`: 32 or more random characters
2. Give the UI container `API_INTERNAL_URL` (compose sets `http://api:8000`). It then forwards these paths to the API: `/.well-known/webfinger`, `/.well-known/nodeinfo`, `/.well-known/host-meta`, `/nodeinfo/`, `/users/`, `/inbox` and `/actor`.
3. Serve the UI over HTTPS on that domain. Other servers only talk to HTTPS.
Handles and actor URLs **can't change once anyone follows** a user, so choose the domain carefully.
`FEDERATION_KEY_SECRET` encrypts each user's signing key. **Back it up, and never change it**: losing it means users' keys can't be read, and followers would have to follow again.
## Develop
```sh
+2
View File
@@ -1,5 +1,7 @@
# ActivityPub phase 1: discoverable profile
**Status: done** on `feature/activitypub` (`98c6554` … `913ef67`). The one gap is the manual check with a real Mastodon account through a tunnel: it's still to do, and needs a public HTTPS address.
This implements phase 1 of [activitypub.md](activitypub.md). Handles and actor URLs are on the **UI's domain**, and posts are **followers only by default** (a per-user setting).
**Outcome:** once an operator enables federation, a user can switch on sharing, and searching `@alice@<UI host>` from Mastodon finds their profile. Following needs phase 2 (the inbox and deliveries). Until then the actor advertises `manuallyApprovesFollowers: true`, so a follow shows as a pending request rather than failing silently. With federation off, nothing changes.
+21
View File
@@ -31,6 +31,27 @@ or switched off without touching anything else. Design: `docs/design/activitypub
| `FEDERATION_ENABLED` | `1` to turn federation on (default off) |
| `FEDERATION_DOMAIN` | Handle domain, normally the web UI's host: users are `@name@<domain>`. **Permanent once anyone follows.** |
| `FEDERATION_BASE_URL` | Public `https://` URL actors live under (`<base>/users/<name>`). Normally the web UI's origin, with the UI's nginx forwarding the ActivityPub paths to the API. |
| `FEDERATION_KEY_SECRET` | 32+ characters; encrypts actors' private keys at rest (HKDF → Fernet). **Back it up; never change it.** |
The UI container forwards these paths to the API when `API_INTERNAL_URL` is set (see `docker/ui-config.sh`):
- `/.well-known/webfinger`, `/.well-known/nodeinfo`, `/.well-known/host-meta`
- `/nodeinfo/`, `/users/`, `/inbox`, `/actor`
Every ActivityPub ID is built from `FEDERATION_BASE_URL`, never from the incoming request.
## Layout
| Module | Holds |
|---|---|
| `protocol/` | Pure protocol code: media types, vocabulary, WebFinger, NodeInfo, host-meta |
| `models.py` | `federation_settings` and `federation_keys` |
| `keys.py` | Key pairs, created once and encrypted at rest |
| `sharing.py` | Per-user settings, and who is sharing |
| `web.py` | The endpoints other servers call |
| `api.py` and `schemas.py` | `/api/v1/federation/*` for the web UI |
| `openapi.py` | OpenAPI descriptions of `web.py`'s endpoints |
| `metrics.py` | Federation's own Prometheus metrics |
## Migrations