aboutsummaryrefslogtreecommitdiff
path: root/src/api/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-07-15 15:31:13 +0200
committerAlex Auvolat <alex@adnab.me>2020-07-15 15:31:13 +0200
commit1c70552f959229195cba250039900fddd77284f3 (patch)
tree321ba3583cdd4d0fe6e3465cdca5170ad8e93e83 /src/api/api_server.rs
parent6c7f9704eabad3f19e426371b21f174f7e1dc2cf (diff)
downloadgarage-1c70552f959229195cba250039900fddd77284f3.tar.gz
garage-1c70552f959229195cba250039900fddd77284f3.zip
Validate content MD5 and SHA256 sums for PutObject and UploadPart
Diffstat (limited to 'src/api/api_server.rs')
-rw-r--r--src/api/api_server.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 8ace2b52..6221d784 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -78,7 +78,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
)));
}
- let api_key = check_signature(&garage, &req).await?;
+ let (api_key, content_sha256) = check_signature(&garage, &req).await?;
let allowed = match req.method() {
&Method::HEAD | &Method::GET => api_key.allow_read(&bucket),
_ => api_key.allow_write(&bucket),
@@ -114,7 +114,16 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
// UploadPart query
let part_number = params.get("partnumber").unwrap();
let upload_id = params.get("uploadid").unwrap();
- Ok(handle_put_part(garage, req, &bucket, &key, part_number, upload_id).await?)
+ Ok(handle_put_part(
+ garage,
+ req,
+ &bucket,
+ &key,
+ part_number,
+ upload_id,
+ content_sha256,
+ )
+ .await?)
} else if req.headers().contains_key("x-amz-copy-source") {
// CopyObject query
let copy_source = req.headers().get("x-amz-copy-source").unwrap().to_str()?;
@@ -134,7 +143,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
Ok(handle_copy(garage, &bucket, &key, &source_bucket, &source_key).await?)
} else {
// PutObject query
- Ok(handle_put(garage, req, &bucket, &key).await?)
+ Ok(handle_put(garage, req, &bucket, &key, content_sha256).await?)
}
}
&Method::DELETE => {