Support website publishing #7
2 changed files with 23 additions and 32 deletions
|
@ -156,38 +156,29 @@ impl AdminRpcHandler {
|
|||
)))
|
||||
}
|
||||
BucketOperation::Website(query) => {
|
||||
let bucket = self.get_existing_bucket(&query.bucket).await?;
|
||||
if query.allow && query.deny {
|
||||
return Err(Error::Message(format!("Website can not be both allowed and denied on a bucket")));
|
||||
let mut bucket = self.get_existing_bucket(&query.bucket).await?;
|
||||
|
||||
if !(query.allow ^ query.deny) {
|
||||
return Err(Error::Message(format!(
|
||||
"You must specify exactly one flag, either --allow or --deny"
|
||||
)));
|
||||
}
|
||||
/*
|
||||
if query.allow || query.deny {
|
||||
let exposed = query.allow;
|
||||
|
||||
if let BucketState::Present(state) = bucket.state.get_mut() {
|
||||
let ak = state.authorized_keys;
|
||||
let old_ak = ak.take_and_clear();
|
||||
ak.merge(&old_ak.update_mutator(
|
||||
key_id.to_string(),
|
||||
PermissionSet {
|
||||
allow_read,
|
||||
allow_write,
|
||||
},
|
||||
));
|
||||
state.website.update(query.allow);
|
||||
let msg = if query.allow {
|
||||
format!("Website access allowed for {}", &query.bucket)
|
||||
} else {
|
||||
format!("Website access denied for {}", &query.bucket)
|
||||
};
|
||||
|
||||
Ok(AdminRPC::Ok(msg.to_string()))
|
||||
} else {
|
||||
return Err(Error::Message(format!(
|
||||
quentin marked this conversation as resolved
|
||||
"Bucket is deleted in update_bucket_key"
|
||||
)));
|
||||
quentin marked this conversation as resolved
lx
commented
`update_bucket_key` ?
|
||||
}
|
||||
}
|
||||
|
||||
let msg = if bucket.exposed {
|
||||
"Bucket is exposed as a website."
|
||||
} else {
|
||||
"Bucket is not exposed."
|
||||
};*/
|
||||
|
||||
Ok(AdminRPC::Ok(/*msg*/"".to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl CRDT for BucketState {
|
|||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct BucketParams {
|
||||
pub authorized_keys: crdt::LWWMap<String, PermissionSet>,
|
||||
pub website: crdt::LWW<bool>
|
||||
pub website: crdt::LWW<bool>,
|
||||
}
|
||||
|
||||
impl CRDT for BucketParams {
|
||||
|
@ -59,7 +59,7 @@ impl BucketParams {
|
|||
pub fn new() -> Self {
|
||||
BucketParams {
|
||||
authorized_keys: crdt::LWWMap::new(),
|
||||
website: crdt::LWW::new(false)
|
||||
website: crdt::LWW::new(false),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ impl TableSchema for BucketTable {
|
|||
|
||||
let params = BucketParams {
|
||||
authorized_keys: keys,
|
||||
website: crdt::LWW::new(false)
|
||||
website: crdt::LWW::new(false),
|
||||
};
|
||||
|
||||
Some(Bucket {
|
||||
|
|
Loading…
Reference in a new issue
Probably put
unreachable!()
in else branch ? Because get_existing_bucket does not return a bucket that is deleted. (I think so, this should be checked)Checked.
Indeed, it does not return deleted buckets.