Merge pull request 'Garage v0.8.7' (#758) from fix-presigned-0.8 into main-0.8.x

Reviewed-on: Deuxfleurs/garage#758
This commit is contained in:
Alex 2024-03-04 14:39:06 +00:00
commit a08ac4a3fd
17 changed files with 198 additions and 109 deletions

18
Cargo.lock generated
View file

@ -1216,7 +1216,7 @@ dependencies = [
[[package]]
name = "garage"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"assert-json-diff",
"async-trait",
@ -1268,7 +1268,7 @@ dependencies = [
[[package]]
name = "garage_api"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"argon2",
"async-trait",
@ -1315,7 +1315,7 @@ dependencies = [
[[package]]
name = "garage_block"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"arc-swap",
"async-compression",
@ -1340,7 +1340,7 @@ dependencies = [
[[package]]
name = "garage_db"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"clap 4.4.0",
"err-derive",
@ -1355,7 +1355,7 @@ dependencies = [
[[package]]
name = "garage_model"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"arc-swap",
"async-trait",
@ -1382,7 +1382,7 @@ dependencies = [
[[package]]
name = "garage_rpc"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"arc-swap",
"async-trait",
@ -1414,7 +1414,7 @@ dependencies = [
[[package]]
name = "garage_table"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"arc-swap",
"async-trait",
@ -1436,7 +1436,7 @@ dependencies = [
[[package]]
name = "garage_util"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"arc-swap",
"async-trait",
@ -1470,7 +1470,7 @@ dependencies = [
[[package]]
name = "garage_web"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"err-derive",
"futures",

120
Cargo.nix
View file

@ -33,7 +33,7 @@ args@{
ignoreLockHash,
}:
let
nixifiedLockHash = "f35182f56858732ce73c2ce5e7c8f660a837aca2a703056be8ea39454e17a659";
nixifiedLockHash = "d65c6aea820e421733c3e83dd476f1bb5bb00206ec181275a041404210221bdb";
workspaceSrc = if args.workspaceSrc == null then ./. else args.workspaceSrc;
currentLockHash = builtins.hashFile "sha256" (workspaceSrc + /Cargo.lock);
lockHashIgnored = if ignoreLockHash
@ -57,15 +57,15 @@ in
{
cargo2nixVersion = "0.11.0";
workspace = {
garage_db = rustPackages.unknown.garage_db."0.8.6";
garage_util = rustPackages.unknown.garage_util."0.8.6";
garage_rpc = rustPackages.unknown.garage_rpc."0.8.6";
garage_table = rustPackages.unknown.garage_table."0.8.6";
garage_block = rustPackages.unknown.garage_block."0.8.6";
garage_model = rustPackages.unknown.garage_model."0.8.6";
garage_api = rustPackages.unknown.garage_api."0.8.6";
garage_web = rustPackages.unknown.garage_web."0.8.6";
garage = rustPackages.unknown.garage."0.8.6";
garage_db = rustPackages.unknown.garage_db."0.8.7";
garage_util = rustPackages.unknown.garage_util."0.8.7";
garage_rpc = rustPackages.unknown.garage_rpc."0.8.7";
garage_table = rustPackages.unknown.garage_table."0.8.7";
garage_block = rustPackages.unknown.garage_block."0.8.7";
garage_model = rustPackages.unknown.garage_model."0.8.7";
garage_api = rustPackages.unknown.garage_api."0.8.7";
garage_web = rustPackages.unknown.garage_web."0.8.7";
garage = rustPackages.unknown.garage."0.8.7";
format_table = rustPackages.unknown.format_table."0.1.1";
k2v-client = rustPackages.unknown.k2v-client."0.0.4";
};
@ -1734,9 +1734,9 @@ in
};
});
"unknown".garage."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/garage");
features = builtins.concatLists [
@ -1763,14 +1763,14 @@ in
format_table = (rustPackages."unknown".format_table."0.1.1" { inherit profileName; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
garage_api = (rustPackages."unknown".garage_api."0.8.6" { inherit profileName; }).out;
garage_block = (rustPackages."unknown".garage_block."0.8.6" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.6" { inherit profileName; }).out;
garage_model = (rustPackages."unknown".garage_model."0.8.6" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.6" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_web = (rustPackages."unknown".garage_web."0.8.6" { inherit profileName; }).out;
garage_api = (rustPackages."unknown".garage_api."0.8.7" { inherit profileName; }).out;
garage_block = (rustPackages."unknown".garage_block."0.8.7" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.7" { inherit profileName; }).out;
garage_model = (rustPackages."unknown".garage_model."0.8.7" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.7" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
garage_web = (rustPackages."unknown".garage_web."0.8.7" { inherit profileName; }).out;
git_version = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".git-version."0.3.5" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
sodiumoxide = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".kuska-sodiumoxide."0.2.5-0" { inherit profileName; }).out;
@ -1807,9 +1807,9 @@ in
};
});
"unknown".garage_api."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_api."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_api";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/api");
features = builtins.concatLists [
@ -1829,11 +1829,11 @@ in
form_urlencoded = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".form_urlencoded."1.2.0" { inherit profileName; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
garage_block = (rustPackages."unknown".garage_block."0.8.6" { inherit profileName; }).out;
garage_model = (rustPackages."unknown".garage_model."0.8.6" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.6" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_block = (rustPackages."unknown".garage_block."0.8.7" { inherit profileName; }).out;
garage_model = (rustPackages."unknown".garage_model."0.8.7" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.7" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
hmac = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hmac."0.12.1" { inherit profileName; }).out;
http = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".http."0.2.9" { inherit profileName; }).out;
@ -1863,9 +1863,9 @@ in
};
});
"unknown".garage_block."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_block."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_block";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/block");
features = builtins.concatLists [
@ -1878,10 +1878,10 @@ in
bytes = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".bytes."1.4.0" { inherit profileName; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.6" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.6" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.7" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.7" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
opentelemetry = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".opentelemetry."0.17.0" { inherit profileName; }).out;
rand = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".rand."0.8.5" { inherit profileName; }).out;
@ -1894,9 +1894,9 @@ in
};
});
"unknown".garage_db."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_db."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_db";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/db");
features = builtins.concatLists [
@ -1926,9 +1926,9 @@ in
};
});
"unknown".garage_model."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_model."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_model";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/model");
features = builtins.concatLists [
@ -1946,11 +1946,11 @@ in
err_derive = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
garage_block = (rustPackages."unknown".garage_block."0.8.6" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.6" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.6" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_block = (rustPackages."unknown".garage_block."0.8.7" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.7" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.7" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
netapp = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".netapp."0.5.2" { inherit profileName; }).out;
opentelemetry = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".opentelemetry."0.17.0" { inherit profileName; }).out;
@ -1963,9 +1963,9 @@ in
};
});
"unknown".garage_rpc."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_rpc."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_rpc";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/rpc");
features = builtins.concatLists [
@ -1985,8 +1985,8 @@ in
${ if rootFeatures' ? "garage/consul-discovery" || rootFeatures' ? "garage_rpc/consul-discovery" || rootFeatures' ? "garage_rpc/err-derive" then "err_derive" else null } = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
gethostname = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".gethostname."0.4.3" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
${ if rootFeatures' ? "garage/kubernetes-discovery" || rootFeatures' ? "garage_rpc/k8s-openapi" || rootFeatures' ? "garage_rpc/kubernetes-discovery" then "k8s_openapi" else null } = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".k8s-openapi."0.16.0" { inherit profileName; }).out;
@ -2008,9 +2008,9 @@ in
};
});
"unknown".garage_table."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_table."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_table";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/table");
dependencies = {
@ -2019,9 +2019,9 @@ in
bytes = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".bytes."1.4.0" { inherit profileName; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.6" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.7" { inherit profileName; }).out;
garage_rpc = (rustPackages."unknown".garage_rpc."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
hexdump = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hexdump."0.1.1" { inherit profileName; }).out;
opentelemetry = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".opentelemetry."0.17.0" { inherit profileName; }).out;
@ -2033,9 +2033,9 @@ in
};
});
"unknown".garage_util."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_util."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_util";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/util");
features = builtins.concatLists [
@ -2051,7 +2051,7 @@ in
digest = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".digest."0.10.7" { inherit profileName; }).out;
err_derive = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.6" { inherit profileName; }).out;
garage_db = (rustPackages."unknown".garage_db."0.8.7" { inherit profileName; }).out;
hex = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hex."0.4.3" { inherit profileName; }).out;
hexdump = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hexdump."0.1.1" { inherit profileName; }).out;
http = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".http."0.2.9" { inherit profileName; }).out;
@ -2077,18 +2077,18 @@ in
};
});
"unknown".garage_web."0.8.6" = overridableMkRustCrate (profileName: rec {
"unknown".garage_web."0.8.7" = overridableMkRustCrate (profileName: rec {
name = "garage_web";
version = "0.8.6";
version = "0.8.7";
registry = "unknown";
src = fetchCrateLocal (workspaceSrc + "/src/web");
dependencies = {
err_derive = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
garage_api = (rustPackages."unknown".garage_api."0.8.6" { inherit profileName; }).out;
garage_model = (rustPackages."unknown".garage_model."0.8.6" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.6" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.6" { inherit profileName; }).out;
garage_api = (rustPackages."unknown".garage_api."0.8.7" { inherit profileName; }).out;
garage_model = (rustPackages."unknown".garage_model."0.8.7" { inherit profileName; }).out;
garage_table = (rustPackages."unknown".garage_table."0.8.7" { inherit profileName; }).out;
garage_util = (rustPackages."unknown".garage_util."0.8.7" { inherit profileName; }).out;
http = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".http."0.2.9" { inherit profileName; }).out;
hyper = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hyper."0.14.27" { inherit profileName; }).out;
hyperlocal = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".hyperlocal."0.8.0" { inherit profileName; }).out;

View file

@ -18,14 +18,14 @@ default-members = ["src/garage"]
[workspace.dependencies]
format_table = { version = "0.1.1", path = "src/format-table" }
garage_api = { version = "0.8.6", path = "src/api" }
garage_block = { version = "0.8.6", path = "src/block" }
garage_db = { version = "0.8.6", path = "src/db", default-features = false }
garage_model = { version = "0.8.6", path = "src/model", default-features = false }
garage_rpc = { version = "0.8.6", path = "src/rpc" }
garage_table = { version = "0.8.6", path = "src/table" }
garage_util = { version = "0.8.6", path = "src/util" }
garage_web = { version = "0.8.6", path = "src/web" }
garage_api = { version = "0.8.7", path = "src/api" }
garage_block = { version = "0.8.7", path = "src/block" }
garage_db = { version = "0.8.7", path = "src/db", default-features = false }
garage_model = { version = "0.8.7", path = "src/model", default-features = false }
garage_rpc = { version = "0.8.7", path = "src/rpc" }
garage_table = { version = "0.8.7", path = "src/table" }
garage_util = { version = "0.8.7", path = "src/util" }
garage_web = { version = "0.8.7", path = "src/web" }
k2v-client = { version = "0.0.4", path = "src/k2v-client" }
[profile.dev]

View file

@ -21,4 +21,4 @@ version: 0.4.1
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.8.6"
appVersion: "v0.8.7"

View file

@ -1,6 +1,6 @@
[package]
name = "garage_api"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -31,7 +31,13 @@ pub const AWS4_HMAC_SHA256: &str = "AWS4-HMAC-SHA256";
pub const UNSIGNED_PAYLOAD: &str = "UNSIGNED-PAYLOAD";
pub const STREAMING_AWS4_HMAC_SHA256_PAYLOAD: &str = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD";
pub type QueryMap = HashMap<String, String>;
pub type QueryMap = HeaderMap<QueryValue>;
pub struct QueryValue {
/// Original key with potential uppercase characters,
/// for use in signature calculation
key: String,
value: String,
}
pub async fn check_payload_signature(
garage: &Garage,
@ -40,7 +46,7 @@ pub async fn check_payload_signature(
) -> Result<(Option<Key>, Option<Hash>), Error> {
let query = parse_query_map(request.uri())?;
if query.contains_key(X_AMZ_ALGORITHM.as_str()) {
if query.contains_key(&X_AMZ_ALGORITHM) {
// We check for presigned-URL-style authentification first, because
// the browser or someting else could inject an Authorization header
// that is totally unrelated to AWS signatures.
@ -121,8 +127,8 @@ async fn check_presigned_signature(
request: &mut Request<Body>,
mut query: QueryMap,
) -> Result<(Option<Key>, Option<Hash>), Error> {
let algorithm = query.get(X_AMZ_ALGORITHM.as_str()).unwrap();
let authorization = Authorization::parse_presigned(algorithm, &query)?;
let algorithm = query.get(&X_AMZ_ALGORITHM).unwrap();
let authorization = Authorization::parse_presigned(&algorithm.value, &query)?;
// Verify that all necessary request headers are included in signed_headers
// For AWSv4 pre-signed URLs, the following must be incldued:
@ -135,7 +141,7 @@ async fn check_presigned_signature(
// but the signature cannot be computed from a string that contains itself.
// AWS specifies that all query params except X-Amz-Signature are included
// in the canonical request.
query.remove(X_AMZ_SIGNATURE.as_str());
query.remove(&X_AMZ_SIGNATURE);
let canonical_request = canonical_request(
service,
request.method(),
@ -161,10 +167,8 @@ async fn check_presigned_signature(
// then an InvalidRequest error is raised.
let headers_mut = request.headers_mut();
for (name, value) in query.iter() {
let name =
HeaderName::from_bytes(name.as_bytes()).ok_or_bad_request("Invalid header name")?;
if let Some(existing) = headers_mut.get(&name) {
if signed_headers.contains(&name) && existing.as_bytes() != value.as_bytes() {
if let Some(existing) = headers_mut.get(name) {
if signed_headers.contains(&name) && existing.as_bytes() != value.value.as_bytes() {
return Err(Error::bad_request(format!(
"Conflicting values for `{}` in query parameters and request headers",
name
@ -180,7 +184,7 @@ async fn check_presigned_signature(
// that are not signed, however there is not much reason that this would happen)
headers_mut.insert(
name,
HeaderValue::from_bytes(value.as_bytes())
HeaderValue::from_bytes(value.value.as_bytes())
.ok_or_bad_request("invalid query parameter value")?,
);
}
@ -192,11 +196,19 @@ async fn check_presigned_signature(
}
pub fn parse_query_map(uri: &http::uri::Uri) -> Result<QueryMap, Error> {
let mut query = QueryMap::new();
let mut query = QueryMap::with_capacity(0);
if let Some(query_str) = uri.query() {
let query_pairs = url::form_urlencoded::parse(query_str.as_bytes());
for (key, val) in query_pairs {
if query.insert(key.to_string(), val.into_owned()).is_some() {
let name =
HeaderName::from_bytes(key.as_bytes()).ok_or_bad_request("Invalid header name")?;
let value = QueryValue {
key: key.to_string(),
value: val.into_owned(),
};
if query.insert(name, value).is_some() {
return Err(Error::bad_request(format!(
"duplicate query parameter: `{}`",
key
@ -305,7 +317,7 @@ pub fn canonical_request(
// Canonical query string from passed HeaderMap
let canonical_query_string = {
let mut items = Vec::with_capacity(query.len());
for (key, value) in query.iter() {
for (_, QueryValue { key, value }) in query.iter() {
items.push(uri_encode(&key, true) + "=" + &uri_encode(&value, true));
}
items.sort();
@ -463,18 +475,19 @@ impl Authorization {
}
let cred = query
.get(X_AMZ_CREDENTIAL.as_str())
.get(&X_AMZ_CREDENTIAL)
.ok_or_bad_request("X-Amz-Credential not found in query parameters")?;
let signed_headers = query
.get(X_AMZ_SIGNEDHEADERS.as_str())
.get(&X_AMZ_SIGNEDHEADERS)
.ok_or_bad_request("X-Amz-SignedHeaders not found in query parameters")?;
let signature = query
.get(X_AMZ_SIGNATURE.as_str())
.get(&X_AMZ_SIGNATURE)
.ok_or_bad_request("X-Amz-Signature not found in query parameters")?;
let duration = query
.get(X_AMZ_EXPIRES.as_str())
.get(&X_AMZ_EXPIRES)
.ok_or_bad_request("X-Amz-Expires not found in query parameters")?
.value
.parse()
.map_err(|_| Error::bad_request("X-Amz-Expires is not a number".to_string()))?;
@ -485,20 +498,20 @@ impl Authorization {
}
let date = query
.get(X_AMZ_DATE.as_str())
.get(&X_AMZ_DATE)
.ok_or_bad_request("Missing X-Amz-Date field")?;
let date = parse_date(date)?;
let date = parse_date(&date.value)?;
if Utc::now() - date > Duration::seconds(duration) {
return Err(Error::bad_request("Date is too old".to_string()));
}
let (key_id, scope) = parse_credential(cred)?;
let (key_id, scope) = parse_credential(&cred.value)?;
Ok(Authorization {
key_id,
scope,
signed_headers: signed_headers.to_string(),
signature: signature.to_string(),
signed_headers: signed_headers.value.clone(),
signature: signature.value.clone(),
content_sha256: UNSIGNED_PAYLOAD.to_string(),
date,
})

View file

@ -1,6 +1,6 @@
[package]
name = "garage_block"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -1,6 +1,6 @@
[package]
name = "garage_db"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -1,6 +1,6 @@
[package]
name = "garage"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -59,6 +59,10 @@ impl CustomRequester {
vhost_style: false,
}
}
pub fn client(&self) -> &Client<HttpConnector, Body> {
&self.client
}
}
pub struct RequestBuilder<'a> {

View file

@ -1,6 +1,7 @@
mod list;
mod multipart;
mod objects;
mod presigned;
mod simple;
mod streaming_signature;
mod website;

View file

@ -0,0 +1,71 @@
use std::time::{Duration, SystemTime};
use crate::common;
use aws_sdk_s3::presigning::PresigningConfig;
use bytes::Bytes;
use hyper::{Body, Request};
const STD_KEY: &str = "hello world";
const BODY: &[u8; 62] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
#[tokio::test]
async fn test_presigned_url() {
let ctx = common::context();
let bucket = ctx.create_bucket("presigned");
let etag = "\"46cf18a9b447991b450cad3facf5937e\"";
let body = Bytes::from(BODY.to_vec());
let psc = PresigningConfig::builder()
.start_time(SystemTime::now() - Duration::from_secs(60))
.expires_in(Duration::from_secs(3600))
.build()
.unwrap();
{
// PutObject
let req = ctx
.client
.put_object()
.bucket(&bucket)
.key(STD_KEY)
.presigned(psc.clone())
.await
.unwrap();
let client = ctx.custom_request.client();
let req = Request::builder()
.method("PUT")
.uri(req.uri())
.body(body.clone().into())
.unwrap();
let res = client.request(req).await.unwrap();
assert_eq!(res.status(), 200);
assert_eq!(res.headers().get("etag").unwrap(), etag);
}
{
// GetObject
let req = ctx
.client
.get_object()
.bucket(&bucket)
.key(STD_KEY)
.presigned(psc)
.await
.unwrap();
let client = ctx.custom_request.client();
let req = Request::builder()
.method("GET")
.uri(req.uri())
.body(Body::empty())
.unwrap();
let res = client.request(req).await.unwrap();
assert_eq!(res.status(), 200);
assert_eq!(res.headers().get("etag").unwrap(), etag);
let body2 = hyper::body::to_bytes(res.into_body()).await.unwrap();
assert_eq!(body, body2);
}
}

View file

@ -1,6 +1,6 @@
[package]
name = "garage_model"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -1,6 +1,6 @@
[package]
name = "garage_rpc"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -1,6 +1,6 @@
[package]
name = "garage_table"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -1,6 +1,6 @@
[package]
name = "garage_util"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"

View file

@ -1,6 +1,6 @@
[package]
name = "garage_web"
version = "0.8.6"
version = "0.8.7"
authors = ["Alex Auvolat <alex@adnab.me>", "Quentin Dufour <quentin@dufour.io>"]
edition = "2018"
license = "AGPL-3.0"