garage_api(fixup): Verify Content-SHA256 header for multipart upload only when needed.
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
Jill 2022-01-14 14:09:18 +01:00
parent b2eda2c13e
commit 11a1f3f6cf
Signed by: KokaKiwi
GPG key ID: 09A5A2688F13FAC1

View file

@ -504,11 +504,11 @@ pub async fn handle_complete_multipart_upload(
upload_id: &str, upload_id: &str,
content_sha256: Option<Hash>, content_sha256: Option<Hash>,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let content_sha256 =
content_sha256.ok_or_bad_request("Request content hash not signed, aborting.")?;
let body = hyper::body::to_bytes(req.into_body()).await?; let body = hyper::body::to_bytes(req.into_body()).await?;
if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;
}
let body_xml = roxmltree::Document::parse(std::str::from_utf8(&body)?)?; let body_xml = roxmltree::Document::parse(std::str::from_utf8(&body)?)?;
let body_list_of_parts = parse_complete_multpart_upload_body(&body_xml) let body_list_of_parts = parse_complete_multpart_upload_body(&body_xml)