aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/access.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 21:30:24 +0000
committertv <tv@krebsco.de>2026-11-16 23:04:45 +0100
commit9fa28bb06692cd3e9d06b678d3dfe2595d328a5f (patch)
treea4e2959a984f0bd0d416042b9d93e7f2971122aa /src/api/access.rs
parentd46368d5ba8d7a12e657b5f293830b6c0d8dce00 (diff)
api: a swarm holding a store at a node's API
Behind the `federation` feature, a node of a swarm holding a store has, at its API (`docs/store.md`, Members; `docs/openapi.yaml`, Events): * `GET /events`: its store's ID, its checkpoint's, its heads, and how many events it took after its checkpoint; * `POST /events`: an event put, whoever signed it, offered to the store and written into the document at its ID unless the store refuses it (`422`, with why): taken, held, or waiting for what it builds on; * `GET /events/{id}`: an event the store holds, or its checkpoint, as its bytes; * `GET /events/counts`: what counts as the store reads now: the current version, each party's keys and nodes, the values at places, the members; * `GET /events/refused`: what the store refused, its own refusals apart, its operator's drops, and the rest with why; * `POST /admin/events/drop` and `/admin/events/allow`: its operator has it drop what it took, and take it back. The events' endpoints are anyone's this node lets in, as the store's are; dropping and taking back need `write` on `_continuum`, as what operators do. While a node holds no store, they answer `404`.
Diffstat (limited to 'src/api/access.rs')
-rw-r--r--src/api/access.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/api/access.rs b/src/api/access.rs
index ddcaad0..9157e1d 100644
--- a/src/api/access.rs
+++ b/src/api/access.rs
@@ -274,7 +274,7 @@ fn needed(method: &Method, path: &str, node: &str) -> Need {
let under = |prefix: &str| path == prefix || path.starts_with(&format!("{prefix}/"));
// What this node holds alone: `_continuum/local/<node>/<name>`, never stored.
let local = |right, name: &str| protocol(right, &[meta::LOCAL, node, name]);
- if under("/store") || under("/stream") {
+ if under("/store") || under("/stream") || under("/events") {
Need::Store
} else if (under("/auth/keys") && !looking) || path == "/auth/logout" {
Need::Credentials
@@ -482,6 +482,12 @@ mod tests {
assert_eq!(needed(&Method::GET, "/auth/whoami", "n1"), Need::Auth);
assert_eq!(needed(&Method::PUT, "/store/a/b", "n1"), Need::Store);
assert_eq!(needed(&Method::GET, "/stream/a", "n1"), Need::Store);
+ assert_eq!(needed(&Method::POST, "/events", "n1"), Need::Store);
+ assert_eq!(needed(&Method::GET, "/events/counts", "n1"), Need::Store);
+ assert_eq!(
+ needed(&Method::POST, "/admin/events/drop", "n1"),
+ write(&[])
+ );
assert_eq!(needed(&Method::GET, "/storehouse", "n1"), read(&[]));
assert_eq!(needed(&Method::GET, "/peers", "n1"), Need::Observe);
assert_eq!(needed(&Method::GET, "/admin/stats", "n1"), Need::Observe);