~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

A former member's files are fetched no more

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/space-blob-writers
crates/group-host/src/index_api.rs+8−3
@@ -5,6 +5,7 @@
use crate::Host;
use crate::api::{Params, invalid, page, param};
use crate::authority::Access::Write;
use crate::group_api::{caller, group_of};
use crate::rbac::{Access, NS};
use crate::time::iso;
@@ -192,10 +193,14 @@ impl Host {
repo: &str,
cid: &Cid,
) -> Option<(String, Vec<u8>)> {
// Only a writer of the space: any other DID would have the host ask
// a server of the caller's choosing, with the group's credential.
// Only a writer of the space, and one it still lets write, as the
// index keeps: any other DID would have the host ask a server of
// the caller's choosing, with the group's credential, and one put
// out has what they wrote there forgotten.
let writers = self.store.writers(space, None, u32::MAX).ok()?;
if !writers.iter().any(|w| w.did == repo) {
let hosted = self.store.space(space).ok()??;
let writes = self.may(space, &hosted, Some(repo), Write).ok()?;
if !writes || !writers.iter().any(|w| w.did == repo) {
return None;
}
let here = self
crates/group-host/tests/index.rs+32−0
@@ -779,6 +779,38 @@ async fn fetches_no_file_too_big_or_not_asked_for() {
.await;
assert_eq!(got.status == 200, ok);
}
// One no longer a member, though still in the writer set: their files
// are fetched no more.
fake.answers.lock().unwrap().insert(
"getBlob".into(),
vec![Answer {
status: 200,
body: small.clone(),
vouch: None,
}],
);
let membership = (format!("{NS}.membership"), writer.to_string());
h.host
.space_write(
&did,
&members_space(&did),
&[Write::Delete {
collection: membership.0,
rkey: membership.1,
}],
)
.await
.unwrap();
let asked = *fake.asked.lock().unwrap();
let got = read(
&h,
&lxm,
&fetch(&Cid::of_raw(&small).to_string()),
&[auth(&h, &alice, &lxm)],
)
.await;
assert_eq!(got.error(), (400, "NotFound".into()));
assert_eq!(*fake.asked.lock().unwrap(), asked);
// A writer whose host is not found.
h.host
.store