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/api | |
| 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/api')
| -rw-r--r-- | src/api/login.rs | 26 |
1 files changed, 14 insertions, 12 deletions
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<token::Refused> { 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(), } } |
