From 348a9a4cd6f550b2857b4ddf1a476234197c2618 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 28 Jan 2025 18:53:44 +0100 Subject: [PATCH] admin api: rename allow/deny api calls in api v2 --- doc/api/garage-admin-v2.yml | 8 ++++---- doc/drafts/admin-api.md | 4 ++-- src/api/admin/api.rs | 16 ++++++++-------- src/api/admin/bucket.rs | 20 ++++++++++---------- src/api/admin/router_v2.rs | 8 ++++---- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/doc/api/garage-admin-v2.yml b/doc/api/garage-admin-v2.yml index 07df11ad..9ee1cf63 100644 --- a/doc/api/garage-admin-v2.yml +++ b/doc/api/garage-admin-v2.yml @@ -826,11 +826,11 @@ paths: schema: $ref: '#/components/schemas/BucketInfo' - /BucketAllowKey: + /AllowBucketKey: post: tags: - Permissions - operationId: "BucketAllowKey" + operationId: "AllowBucketKey" summary: "Allow key" description: | ⚠️ **DISCLAIMER**: Garage's developers are aware that this endpoint has an unconventional semantic. Be extra careful when implementing it, its behavior is not obvious. @@ -886,11 +886,11 @@ paths: schema: $ref: '#/components/schemas/BucketInfo' - /BucketDenyKey: + /DenyBucketKey: post: tags: - Permissions - operationId: "BucketDenyKey" + operationId: "DenyBucketKey" summary: "Deny key" description: | ⚠️ **DISCLAIMER**: Garage's developers are aware that this endpoint has an unconventional semantic. Be extra careful when implementing it, its behavior is not obvious. diff --git a/doc/drafts/admin-api.md b/doc/drafts/admin-api.md index 6833f251..1fbe7c40 100644 --- a/doc/drafts/admin-api.md +++ b/doc/drafts/admin-api.md @@ -705,7 +705,7 @@ Warning: this will delete all aliases associated with the bucket! ### Operations on permissions for keys on buckets -#### BucketAllowKey `POST /v2/BucketAllowKey` +#### AllowBucketKey `POST /v2/AllowBucketKey` Allows a key to do read/write/owner operations on a bucket. @@ -726,7 +726,7 @@ Request body format: Flags in `permissions` which have the value `true` will be activated. Other flags will remain unchanged. -#### BucketDenyKey `POST /v2/BucketDenyKey` +#### DenyBucketKey `POST /v2/DenyBucketKey` Denies a key from doing read/write/owner operations on a bucket. diff --git a/src/api/admin/api.rs b/src/api/admin/api.rs index 632711d1..c3559587 100644 --- a/src/api/admin/api.rs +++ b/src/api/admin/api.rs @@ -50,8 +50,8 @@ admin_endpoints![ DeleteBucket, // Operations on permissions for keys on buckets - BucketAllowKey, - BucketDenyKey, + AllowBucketKey, + DenyBucketKey, // Operations on bucket aliases AddGlobalBucketAlias, @@ -486,13 +486,13 @@ pub struct DeleteBucketResponse; // Operations on permissions for keys on buckets // ********************************************** -// ---- BucketAllowKey ---- +// ---- AllowBucketKey ---- #[derive(Serialize, Deserialize)] -pub struct BucketAllowKeyRequest(pub BucketKeyPermChangeRequest); +pub struct AllowBucketKeyRequest(pub BucketKeyPermChangeRequest); #[derive(Serialize, Deserialize)] -pub struct BucketAllowKeyResponse(pub GetBucketInfoResponse); +pub struct AllowBucketKeyResponse(pub GetBucketInfoResponse); #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -502,13 +502,13 @@ pub struct BucketKeyPermChangeRequest { pub permissions: ApiBucketKeyPerm, } -// ---- BucketDenyKey ---- +// ---- DenyBucketKey ---- #[derive(Serialize, Deserialize)] -pub struct BucketDenyKeyRequest(pub BucketKeyPermChangeRequest); +pub struct DenyBucketKeyRequest(pub BucketKeyPermChangeRequest); #[derive(Serialize, Deserialize)] -pub struct BucketDenyKeyResponse(pub GetBucketInfoResponse); +pub struct DenyBucketKeyResponse(pub GetBucketInfoResponse); // ********************************************** // Operations on bucket aliases diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 09952bff..885c1749 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -18,8 +18,8 @@ use garage_model::s3::object_table::*; use crate::admin::api::ApiBucketKeyPerm; use crate::admin::api::{ - ApiBucketQuotas, BucketAllowKeyRequest, BucketAllowKeyResponse, BucketDenyKeyRequest, - BucketDenyKeyResponse, BucketKeyPermChangeRequest, BucketLocalAlias, CreateBucketRequest, + ApiBucketQuotas, AllowBucketKeyRequest, AllowBucketKeyResponse, DenyBucketKeyRequest, + DenyBucketKeyResponse, BucketKeyPermChangeRequest, BucketLocalAlias, CreateBucketRequest, CreateBucketResponse, DeleteBucketRequest, DeleteBucketResponse, GetBucketInfoKey, GetBucketInfoRequest, GetBucketInfoResponse, GetBucketInfoWebsiteResponse, AddGlobalBucketAliasRequest, AddGlobalBucketAliasResponse, RemoveGlobalBucketAliasRequest, @@ -394,22 +394,22 @@ impl EndpointHandler for UpdateBucketRequest { // ---- BUCKET/KEY PERMISSIONS ---- #[async_trait] -impl EndpointHandler for BucketAllowKeyRequest { - type Response = BucketAllowKeyResponse; +impl EndpointHandler for AllowBucketKeyRequest { + type Response = AllowBucketKeyResponse; - async fn handle(self, garage: &Arc) -> Result { + async fn handle(self, garage: &Arc) -> Result { let res = handle_bucket_change_key_perm(garage, self.0, true).await?; - Ok(BucketAllowKeyResponse(res)) + Ok(AllowBucketKeyResponse(res)) } } #[async_trait] -impl EndpointHandler for BucketDenyKeyRequest { - type Response = BucketDenyKeyResponse; +impl EndpointHandler for DenyBucketKeyRequest { + type Response = DenyBucketKeyResponse; - async fn handle(self, garage: &Arc) -> Result { + async fn handle(self, garage: &Arc) -> Result { let res = handle_bucket_change_key_perm(garage, self.0, false).await?; - Ok(BucketDenyKeyResponse(res)) + Ok(DenyBucketKeyResponse(res)) } } diff --git a/src/api/admin/router_v2.rs b/src/api/admin/router_v2.rs index 6faa2ab1..45613ea4 100644 --- a/src/api/admin/router_v2.rs +++ b/src/api/admin/router_v2.rs @@ -52,8 +52,8 @@ impl AdminApiRequest { POST DeleteBucket (query::id), POST UpdateBucket (body_field, query::id), // Bucket-key permissions - POST BucketAllowKey (body), - POST BucketDenyKey (body), + POST AllowBucketKey (body), + POST DenyBucketKey (body), // Bucket aliases POST AddGlobalBucketAlias (body), POST RemoveGlobalBucketAlias (body), @@ -167,11 +167,11 @@ impl AdminApiRequest { // Bucket-key permissions Endpoint::BucketAllowKey => { let req = parse_json_body::(req).await?; - Ok(AdminApiRequest::BucketAllowKey(BucketAllowKeyRequest(req))) + Ok(AdminApiRequest::AllowBucketKey(AllowBucketKeyRequest(req))) } Endpoint::BucketDenyKey => { let req = parse_json_body::(req).await?; - Ok(AdminApiRequest::BucketDenyKey(BucketDenyKeyRequest(req))) + Ok(AdminApiRequest::DenyBucketKey(DenyBucketKeyRequest(req))) } // Bucket aliasing Endpoint::GlobalAliasBucket { id, alias } => Ok(AdminApiRequest::AddGlobalBucketAlias(