aboutsummaryrefslogtreecommitdiff
path: root/src/api/signature/payload.rs
diff options
context:
space:
mode:
authortrinity-1686a <trinity@deuxfleurs.fr>2022-03-11 17:35:08 +0100
committerGitea <gitea@fake.local>2022-03-23 10:22:36 +0100
commit1eb7fdb08fed59a9e78adc24df2d96fda746c560 (patch)
tree4dd507a8676011c0793938cb37408870e93193a7 /src/api/signature/payload.rs
parente934934f149da1f4288359dcc3b6d9b9b284525e (diff)
downloadgarage-1eb7fdb08fed59a9e78adc24df2d96fda746c560.tar.gz
garage-1eb7fdb08fed59a9e78adc24df2d96fda746c560.zip
add test framework for arbitraty S3 requests
and implement some basic test with it
Diffstat (limited to 'src/api/signature/payload.rs')
-rw-r--r--src/api/signature/payload.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/api/signature/payload.rs b/src/api/signature/payload.rs
index 88b58922..88ec1f00 100644
--- a/src/api/signature/payload.rs
+++ b/src/api/signature/payload.rs
@@ -51,8 +51,7 @@ pub async fn check_payload_signature(
let canonical_request = canonical_request(
request.method(),
- request.uri().path(),
- &canonical_query_string(request.uri()),
+ request.uri(),
&headers,
&authorization.signed_headers,
&authorization.content_sha256,
@@ -215,7 +214,7 @@ fn parse_credential(cred: &str) -> Result<(String, String), Error> {
))
}
-fn string_to_sign(datetime: &DateTime<Utc>, scope_string: &str, canonical_req: &str) -> String {
+pub fn string_to_sign(datetime: &DateTime<Utc>, scope_string: &str, canonical_req: &str) -> String {
let mut hasher = Sha256::default();
hasher.update(canonical_req.as_bytes());
[
@@ -227,18 +226,17 @@ fn string_to_sign(datetime: &DateTime<Utc>, scope_string: &str, canonical_req: &
.join("\n")
}
-fn canonical_request(
+pub fn canonical_request(
method: &Method,
- url_path: &str,
- canonical_query_string: &str,
+ uri: &hyper::Uri,
headers: &HashMap<String, String>,
signed_headers: &str,
content_sha256: &str,
) -> String {
[
method.as_str(),
- url_path,
- canonical_query_string,
+ &uri.path().to_string(),
+ &canonical_query_string(uri),
&canonical_header_string(headers, signed_headers),
"",
signed_headers,