aboutsummaryrefslogtreecommitdiff
path: root/src/garage/admin_rpc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/garage/admin_rpc.rs')
-rw-r--r--src/garage/admin_rpc.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/garage/admin_rpc.rs b/src/garage/admin_rpc.rs
index a23d3e95..e1981e3a 100644
--- a/src/garage/admin_rpc.rs
+++ b/src/garage/admin_rpc.rs
@@ -89,7 +89,7 @@ impl AdminRpcHandler {
}
bucket
.state
- .update(BucketState::Present(crdt::LWWMap::new()));
+ .update(BucketState::Present(BucketParams::new()));
bucket
}
None => Bucket::new(query.name.clone()),
@@ -155,6 +155,29 @@ impl AdminRpcHandler {
&query.key_id, &query.bucket, allow_read, allow_write
)))
}
+ BucketOperation::Website(query) => {
+ 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 let BucketState::Present(state) = bucket.state.get_mut() {
+ state.website.update(query.allow);
+ self.garage.bucket_table.insert(&bucket).await?;
+ 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 {
+ unreachable!();
+ }
+ }
}
}
@@ -237,6 +260,7 @@ impl AdminRpcHandler {
.unwrap_or(Err(Error::BadRPC(format!("Key {} does not exist", id))))
}
+ /// Update **bucket table** to inform of the new linked key
async fn update_bucket_key(
&self,
mut bucket: Bucket,
@@ -244,7 +268,8 @@ impl AdminRpcHandler {
allow_read: bool,
allow_write: bool,
) -> Result<(), Error> {
- if let BucketState::Present(ak) = bucket.state.get_mut() {
+ if let BucketState::Present(params) = bucket.state.get_mut() {
+ let ak = &mut params.authorized_keys;
let old_ak = ak.take_and_clear();
ak.merge(&old_ak.update_mutator(
key_id.to_string(),
@@ -262,6 +287,7 @@ impl AdminRpcHandler {
Ok(())
}
+ /// Update **key table** to inform of the new linked bucket
async fn update_key_bucket(
&self,
mut key: Key,