Apply cargo fmt; add trace output when request signature is bad
This commit is contained in:
parent
f22ecb60a8
commit
86fb7bbba5
4 changed files with 9 additions and 13 deletions
|
@ -67,10 +67,7 @@ async fn handler(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handler_inner(
|
async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Response<Body>, Error> {
|
||||||
garage: Arc<Garage>,
|
|
||||||
req: Request<Body>,
|
|
||||||
) -> Result<Response<Body>, Error> {
|
|
||||||
let path = req.uri().path().to_string();
|
let path = req.uri().path().to_string();
|
||||||
let path = percent_encoding::percent_decode_str(&path).decode_utf8()?;
|
let path = percent_encoding::percent_decode_str(&path).decode_utf8()?;
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,7 @@ pub async fn handle_delete_objects(
|
||||||
|
|
||||||
writeln!(&mut retxml, "</DeleteObjectsOutput>").unwrap();
|
writeln!(&mut retxml, "</DeleteObjectsOutput>").unwrap();
|
||||||
|
|
||||||
Ok(Response::new(Body::from(
|
Ok(Response::new(Body::from(retxml.into_bytes())))
|
||||||
retxml.into_bytes(),
|
|
||||||
)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DeleteRequest {
|
struct DeleteRequest {
|
||||||
|
|
|
@ -176,9 +176,7 @@ pub async fn handle_get_range(
|
||||||
ObjectVersionData::DeleteMarker => Err(Error::NotFound),
|
ObjectVersionData::DeleteMarker => Err(Error::NotFound),
|
||||||
ObjectVersionData::Inline(bytes) => {
|
ObjectVersionData::Inline(bytes) => {
|
||||||
if end as usize <= bytes.len() {
|
if end as usize <= bytes.len() {
|
||||||
let body: Body = Body::from(
|
let body: Body = Body::from(bytes[begin as usize..end as usize].to_vec());
|
||||||
bytes[begin as usize..end as usize].to_vec(),
|
|
||||||
);
|
|
||||||
Ok(resp_builder.body(body)?)
|
Ok(resp_builder.body(body)?)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Message(format!("Internal error: requested range not present in inline bytes when it should have been")))
|
Err(Error::Message(format!("Internal error: requested range not present in inline bytes when it should have been")))
|
||||||
|
|
|
@ -91,6 +91,9 @@ pub async fn check_signature(garage: &Garage, request: &Request<Body>) -> Result
|
||||||
let signature = hex::encode(hmac.result().code());
|
let signature = hex::encode(hmac.result().code());
|
||||||
|
|
||||||
if authorization.signature != signature {
|
if authorization.signature != signature {
|
||||||
|
trace!("Canonical request: ``{}``", canonical_request);
|
||||||
|
trace!("String to sign: ``{}``", string_to_sign);
|
||||||
|
trace!("Expected: {}, got: {}", signature, authorization.signature);
|
||||||
return Err(Error::Forbidden(format!("Invalid signature")));
|
return Err(Error::Forbidden(format!("Invalid signature")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue