aboutsummaryrefslogtreecommitdiff
path: root/src/garage/admin.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-05 15:12:59 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-05 15:12:59 +0100
commit9431090b1eb9006b12395fb22700b0def7fd1f59 (patch)
tree207fc2933484cdb79efc800926bb5d75ac876d8e /src/garage/admin.rs
parent677ab60cc117677bf53dc4887a6ff1c094e17cd0 (diff)
downloadgarage-9431090b1eb9006b12395fb22700b0def7fd1f59.tar.gz
garage-9431090b1eb9006b12395fb22700b0def7fd1f59.zip
Implement key allow|deny --create-bucket
Diffstat (limited to 'src/garage/admin.rs')
-rw-r--r--src/garage/admin.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/garage/admin.rs b/src/garage/admin.rs
index a682075f..509ecaf9 100644
--- a/src/garage/admin.rs
+++ b/src/garage/admin.rs
@@ -429,6 +429,8 @@ impl AdminRpcHandler {
KeyOperation::New(query) => self.handle_create_key(query).await,
KeyOperation::Rename(query) => self.handle_rename_key(query).await,
KeyOperation::Delete(query) => self.handle_delete_key(query).await,
+ KeyOperation::Allow(query) => self.handle_allow_key(query).await,
+ KeyOperation::Deny(query) => self.handle_deny_key(query).await,
KeyOperation::Import(query) => self.handle_import_key(query).await,
}
}
@@ -523,6 +525,34 @@ impl AdminRpcHandler {
)))
}
+ async fn handle_allow_key(&self, query: &KeyPermOpt) -> Result<AdminRpc, Error> {
+ let mut key = self
+ .garage
+ .bucket_helper()
+ .get_existing_matching_key(&query.key_pattern)
+ .await?;
+ key.params_mut()
+ .unwrap()
+ .allow_create_bucket
+ .update(true);
+ self.garage.key_table.insert(&key).await?;
+ self.key_info_result(key).await
+ }
+
+ async fn handle_deny_key(&self, query: &KeyPermOpt) -> Result<AdminRpc, Error> {
+ let mut key = self
+ .garage
+ .bucket_helper()
+ .get_existing_matching_key(&query.key_pattern)
+ .await?;
+ key.params_mut()
+ .unwrap()
+ .allow_create_bucket
+ .update(false);
+ self.garage.key_table.insert(&key).await?;
+ self.key_info_result(key).await
+ }
+
async fn handle_import_key(&self, query: &KeyImportOpt) -> Result<AdminRpc, Error> {
let prev_key = self.garage.key_table.get(&EmptyKey, &query.key_id).await?;
if prev_key.is_some() {