feat(federation): shared libraries and the signed read API for friends
A friend's server can now read what an admin chose to share.
- A library has a shared flag, off by default (migration 0024), set with
PATCH /libraries/{id}. Changing it never waits for a scan.
- Requests between friends are signed with each server's Ed25519 key: the
method, the path and query from /api/v1/peer on, a date, a nonce and the
hash of the empty body. A date more than two minutes off, a nonce used
before, an unknown or removed key and a bad signature all get the same
401. A friend still waiting for approval gets 403, and while federation is
off the routes are missing.
- Routes under /api/v1/peer: info, artists, albums, tracks, covers and
streaming with Range. The catalogue, the counts and the format come from
the shared libraries only, and the file served is the one in a shared
library. No path, library id, listen, taste, user or provider data is part
of an answer.
- A friend never makes this server build a cover, read an audio file or ask
a provider: only covers already built from the audio files are served.
- Per-friend limits, set by the admin: parallel streams (default 3) and KiB
a second (default 4096, 0 for none), shared by all the streams of a friend.
- A log of the last requests friends made (route, status, bytes; never the
query), kept for 7 days, in GET /federation/requests.
- POST /federation/friends/{id}/check lets the side that pasted an invite
find out that the other admin approved; a signed call from a friend this
server is waiting for makes it active too.
- Admin: a Shared with friends switch on each library, which asks first, and
limits, recent requests and a Check button in the Federation section, in
English and Italian.
- OpenAPI paths and schemas, contract test, two real servers checked end to
end with tagged audio files.
This commit is contained in:
parent
346466c621
commit
89826fcd07
1 changed files with 3970 additions and 60 deletions
|
|
@ -317,6 +317,9 @@ func run() error {
|
|||
Settings: userSettings,
|
||||
Streams: streaming.NewService(libraryRepo),
|
||||
Federation: federation.NewService(storage.NewFederationRepo(db), federation.NewClient()),
|
||||
PeerCatalog: catalog.NewService(storage.NewSharedCatalogRepo(db)),
|
||||
PeerStreams: streaming.NewService(libraryRepo.Shared()),
|
||||
PeerCovers: images.StoredOnly{Service: pictures},
|
||||
Web: webui.FS(),
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue