From bb860d2cf0adad80016edb7a7baed4df291b828c Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 30 Nov 2026 14:59:37 +0000 Subject: 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. --- src/api/login.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/api/login.rs') diff --git a/src/api/login.rs b/src/api/login.rs index e442ea2..a5bfde5 100644 --- a/src/api/login.rs +++ b/src/api/login.rs @@ -115,10 +115,12 @@ pub(crate) async fn bearer( let now = state.clock.now_millis().as_u64(); let verified = { let replica = state.doc.read().await; - let verified = token::verify(&replica.doc, &text, &swarm, now); + let entries = state.entries(); + let listed = crate::document::view::members_of(&entries, &replica.doc); + let verified = token::verify(listed, &text, &swarm, now); #[cfg(feature = "federation")] let verified = - verified.and_then(|claims| token::issued_here(&replica.doc, state.local_id(), claims)); + verified.and_then(|claims| token::issued_here(listed, state.local_id(), claims)); verified } .and_then(|claims| { @@ -559,17 +561,17 @@ async fn credentials_end( /// sessions. async fn refused_now(state: &AppState, who: &Credentials) -> Option { let replica = state.doc.read().await; + let entries = state.entries(); + let listed = crate::document::view::members_of(&entries, &replica.doc); match who { - Credentials::Token(claims) => { - token::still_taken(&replica.doc, claims).err().or_else(|| { - state - .ended_sessions - .lock_or_recover() - .contains_key(&claims.session) - .then_some(token::Refused::Ended) - }) - } - Credentials::User(user) => token::user_taken(&replica.doc, user).err(), + Credentials::Token(claims) => token::still_taken(listed, claims).err().or_else(|| { + state + .ended_sessions + .lock_or_recover() + .contains_key(&claims.session) + .then_some(token::Refused::Ended) + }), + Credentials::User(user) => token::user_taken(listed, user).err(), } } -- cgit v1.3.1