diff options
| author | tv <tv@krebsco.de> | 2026-11-30 14:59:37 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 14:59:37 +0000 |
| commit | bb860d2cf0adad80016edb7a7baed4df291b828c (patch) | |
| tree | 7e0bed9ff36df8c5b5432ddd2d7b544278d25f54 /src/federation | |
| parent | 8017b0e69f0350c2a35629ae71d511ddf7a3aa9c (diff) | |
federation: what a set hands the node to read is as a store's document
Beside its members' entries, the policy of a swarm holding a store and
the swarm's ID (Holding::entries): what reads a document for them reads
the same of a node on a set. Tokens are checked against it (api::login):
their issuer's entry is there, and a node takes none another issued, as
the policy says; read of the empty Automerge document beside, every
token was refused.
Diffstat (limited to 'src/federation')
| -rw-r--r-- | src/federation/held.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs index fd43062..bb34407 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -1108,13 +1108,23 @@ impl Holding { } } - /// The members' entries as the node reads them of a document, each at - /// `_continuum/members/<node ID>`, where a set of events carries the store: the - /// document's place for them, which a set keeps apart. + /// What the node reads of its document at paths, where a set of events carries the + /// store: what a document holding a store has there. The members' entries, each at + /// `_continuum/members/<node ID>`, which a set keeps apart; the policy of a swarm + /// holding a store; and the swarm's ID, the store's. pub(crate) fn entries(&self) -> Option<crate::document::view::Tree> { use crate::document::view::{Tree, Write}; self.with_set(|set| { let mut tree = Tree::new(); + // Into a tree of maps alone: nothing is in the way of any of it. + let _ = tree.write_path( + &crate::access::policy::path(), + &events::policy(Federation::NAME), + ); + let _ = tree.write_path( + &meta::path(&[meta::SWARM]), + &serde_json::Value::String(set.store().id().to_string()), + ); for entry in set.entries() { if let Some(value) = entry.value() { let path = [ @@ -1122,7 +1132,6 @@ impl Holding { meta::MEMBERS.to_owned(), entry.node(), ]; - // Into a tree of maps alone: nothing is in the way. let _ = tree.write_path(&path, &serde_json::Value::Object(value)); } } @@ -2966,6 +2975,16 @@ mod tests { Some("tv".to_owned()) ); assert!(holding.member(&key.id(), Some("tv")) == Some(true)); + // And the rest a document holding a store has for the node to read: the + // policy, by which a node takes no token another issued, and the swarm's ID. + assert!(matches!( + crate::access::policy::of(&tree), + crate::access::policy::Policy::Store(_) + )); + assert_eq!( + crate::document::view::read_path(&tree, &meta::path(&[meta::SWARM])).unwrap(), + Some(serde_json::Value::String(Id::of(&root).to_string())) + ); assert!(Holding::default().entries().is_none()); } } |
