aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-28 10:51:08 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-28 12:24:21 +0100
commit90cab5b8f2b5212668975bf445a1e86f638fe1c7 (patch)
tree9bcc9569e7a8806efdf9d542e37ffa06a7689bca /src/api/k2v/api_server.rs
parente9f759d4cb9be28584ab511a0a2dc78b579475c8 (diff)
downloadgarage-90cab5b8f2b5212668975bf445a1e86f638fe1c7.tar.gz
garage-90cab5b8f2b5212668975bf445a1e86f638fe1c7.zip
[fix-presigned] add comments and reorganize
Diffstat (limited to 'src/api/k2v/api_server.rs')
-rw-r--r--src/api/k2v/api_server.rs18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/api/k2v/api_server.rs b/src/api/k2v/api_server.rs
index 5ed7e286..fdb5db4c 100644
--- a/src/api/k2v/api_server.rs
+++ b/src/api/k2v/api_server.rs
@@ -15,8 +15,7 @@ use garage_model::garage::Garage;
use crate::generic_server::*;
use crate::k2v::error::*;
-use crate::signature::payload::check_payload_signature;
-use crate::signature::streaming::*;
+use crate::signature::verify_request;
use crate::helpers::*;
use crate::k2v::batch::*;
@@ -69,7 +68,7 @@ impl ApiHandler for K2VApiServer {
async fn handle(
&self,
- mut req: Request<IncomingBody>,
+ req: Request<IncomingBody>,
endpoint: K2VApiEndpoint,
) -> Result<Response<ResBody>, Error> {
let K2VApiEndpoint {
@@ -86,18 +85,7 @@ impl ApiHandler for K2VApiServer {
return Ok(options_res.map(|_empty_body: EmptyBody| empty_body()));
}
- let (api_key, mut content_sha256) =
- check_payload_signature(&garage, "k2v", &mut req).await?;
- let api_key = api_key
- .ok_or_else(|| Error::forbidden("Garage does not support anonymous access yet"))?;
-
- let req = parse_streaming_body(
- &api_key,
- req,
- &mut content_sha256,
- &garage.config.s3_api.s3_region,
- "k2v",
- )?;
+ let (req, api_key, _content_sha256) = verify_request(&garage, req, "k2v").await?;
let bucket_id = garage
.bucket_helper()