Skip to content

Commit bbd2f08

Browse files
committed
Update to latest versions
1 parent 597f195 commit bbd2f08

File tree

4 files changed

+36
-48
lines changed

4 files changed

+36
-48
lines changed

Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "scratchstack-aws-signature"
3-
version = "0.11.1-preview.4"
3+
version = "0.11.1-preview.5"
44
authors = ["David Cuthbert <dacut@kanga.org>"]
55
description = "AWS SigV4 signature verification"
66
keywords = ["AWS", "Amazon"]
@@ -16,25 +16,25 @@ name = "scratchstack_aws_signature"
1616

1717
[dependencies]
1818
async-trait = "^0.1"
19-
bytes = "^1.2"
19+
bytes = "^1.6"
2020
chrono = { version = "^0.4", default-features = false, features = [ "std" ] }
21-
derive_builder = "^0.11"
21+
derive_builder = "^0.20"
2222
encoding = "^0.2"
2323
futures = "^0.3"
2424
hex = "^0.4"
25-
http = "^0.2"
26-
hyper = { version = "^0.14", features = ["stream"] }
27-
lazy_static = "^1.4"
25+
http = "^1.1"
26+
hyper = "^1.4"
27+
lazy_static = "^1.5"
2828
log = "^0.4"
29-
regex = "^1.6"
30-
ring = "^0.16"
31-
scratchstack-arn = "^0.4"
32-
scratchstack-aws-principal = "^0.4"
33-
scratchstack-errors = "^0.4"
34-
subtle = "^2.4"
29+
regex = "^1.10"
30+
ring = "^0.17"
31+
scratchstack-arn = "^0.4.9"
32+
scratchstack-aws-principal = "^0.4.9"
33+
scratchstack-errors = "^0.4.9"
34+
subtle = "^2.6"
3535
tower = { version = "^0.4", features = [ "util" ] }
3636

3737
[dev-dependencies]
38-
env_logger = "^0.9"
39-
tokio = { version = "^1.21", features = [ "macros", "rt" ] }
38+
env_logger = "^0.11"
39+
tokio = { version = "^1.38", features = [ "macros", "rt" ] }
4040
test-log = "0.2"

src/auth.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ mod tests {
396396
#[test]
397397
fn test_derived() {
398398
init();
399-
let epoch = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp_opt(0, 0).unwrap(), Utc);
400-
let test_time = DateTime::<Utc>::from_utc(
399+
let epoch = DateTime::<Utc>::from_timestamp(0, 0).unwrap();
400+
let test_time = DateTime::<Utc>::from_naive_utc_and_offset(
401401
NaiveDateTime::new(
402402
NaiveDate::from_ymd_opt(2015, 8, 30).unwrap(),
403403
NaiveTime::from_hms_opt(12, 36, 0).unwrap(),
@@ -489,21 +489,21 @@ mod tests {
489489

490490
// Test that the error ordering is correct.
491491
let creq_sha256: [u8; SHA256_OUTPUT_LEN] = [0; SHA256_OUTPUT_LEN];
492-
let test_timestamp = DateTime::<Utc>::from_utc(
492+
let test_timestamp = DateTime::<Utc>::from_naive_utc_and_offset(
493493
NaiveDateTime::new(
494494
NaiveDate::from_ymd_opt(2015, 8, 30).unwrap(),
495495
NaiveTime::from_hms_opt(12, 36, 0).unwrap(),
496496
),
497497
Utc,
498498
);
499-
let outdated_timestamp = DateTime::<Utc>::from_utc(
499+
let outdated_timestamp = DateTime::<Utc>::from_naive_utc_and_offset(
500500
NaiveDateTime::new(
501501
NaiveDate::from_ymd_opt(2015, 8, 30).unwrap(),
502502
NaiveTime::from_hms_opt(12, 20, 59).unwrap(),
503503
),
504504
Utc,
505505
);
506-
let future_timestamp = DateTime::<Utc>::from_utc(
506+
let future_timestamp = DateTime::<Utc>::from_naive_utc_and_offset(
507507
NaiveDateTime::new(
508508
NaiveDate::from_ymd_opt(2015, 8, 30).unwrap(),
509509
NaiveTime::from_hms_opt(12, 51, 1).unwrap(),

src/aws4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async fn run(basename: &str) {
265265
// Create a service for getting the signing key.
266266
let mut signing_key_svc = service_for_signing_key_fn(get_signing_key);
267267

268-
let test_time = DateTime::<Utc>::from_utc(
268+
let test_time = DateTime::<Utc>::from_naive_utc_and_offset(
269269
NaiveDateTime::new(NaiveDate::from_ymd_opt(2015, 8, 30).unwrap(), NaiveTime::from_hms_opt(12, 36, 0).unwrap()),
270270
Utc,
271271
);

src/signature.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ use {
44
SignedHeaderRequirements,
55
},
66
async_trait::async_trait,
7-
bytes::{Bytes, BytesMut},
7+
bytes::Bytes,
88
chrono::{DateTime, Duration, Utc},
9-
futures::stream::StreamExt,
109
http::request::{Parts, Request},
11-
hyper::body::Body as HyperBody,
1210
log::trace,
13-
std::{error::Error, future::Future},
11+
std::future::Future,
1412
tower::{BoxError, Service},
1513
};
1614

@@ -77,42 +75,30 @@ where
7775

7876
#[async_trait]
7977
pub trait IntoRequestBytes {
80-
async fn into_request_bytes(self) -> Result<Bytes, Box<dyn Error + Send + Sync>>;
78+
async fn into_request_bytes(self) -> Result<Bytes, BoxError>;
8179
}
8280

8381
#[async_trait]
8482
impl IntoRequestBytes for () {
85-
async fn into_request_bytes(self) -> Result<Bytes, Box<dyn Error + Send + Sync>> {
83+
async fn into_request_bytes(self) -> Result<Bytes, BoxError> {
8684
Ok(Bytes::new())
8785
}
8886
}
8987

9088
#[async_trait]
9189
impl IntoRequestBytes for Vec<u8> {
92-
async fn into_request_bytes(self) -> Result<Bytes, Box<dyn Error + Send + Sync>> {
90+
async fn into_request_bytes(self) -> Result<Bytes, BoxError> {
9391
Ok(Bytes::from(self))
9492
}
9593
}
9694

9795
#[async_trait]
9896
impl IntoRequestBytes for Bytes {
99-
async fn into_request_bytes(self) -> Result<Bytes, Box<dyn Error + Send + Sync>> {
97+
async fn into_request_bytes(self) -> Result<Bytes, BoxError> {
10098
Ok(self)
10199
}
102100
}
103101

104-
#[async_trait]
105-
impl IntoRequestBytes for HyperBody {
106-
async fn into_request_bytes(mut self) -> Result<Bytes, Box<dyn Error + Send + Sync>> {
107-
let mut body_bytes = BytesMut::new();
108-
while let Some(chunk) = self.next().await {
109-
body_bytes.extend_from_slice(&chunk?);
110-
}
111-
112-
Ok(body_bytes.freeze())
113-
}
114-
}
115-
116102
#[cfg(test)]
117103
mod tests {
118104
use {
@@ -127,20 +113,21 @@ mod tests {
127113
request::{Parts, Request},
128114
uri::{PathAndQuery, Uri},
129115
},
130-
hyper::body::Body as HyperBody,
131116
lazy_static::lazy_static,
132117
scratchstack_aws_principal::{Principal, User},
133118
scratchstack_errors::ServiceError,
134-
std::{convert::Infallible, mem::transmute},
119+
std::mem::transmute,
135120
tower::BoxError,
136121
};
137122

138123
const TEST_REGION: &str = "us-east-1";
139124
const TEST_SERVICE: &str = "service";
140125

141126
lazy_static! {
142-
static ref TEST_TIMESTAMP: DateTime<Utc> =
143-
DateTime::from_local(NaiveDate::from_ymd_opt(2015, 8, 30).unwrap().and_hms_opt(12, 36, 0).unwrap(), Utc);
127+
static ref TEST_TIMESTAMP: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
128+
NaiveDate::from_ymd_opt(2015, 8, 30).unwrap().and_hms_opt(12, 36, 0).unwrap(),
129+
Utc
130+
);
144131
}
145132

146133
macro_rules! expect_err {
@@ -502,8 +489,9 @@ mod tests {
502489
_ => builder = builder.header("x-amz-date", "20150830T122100Z"),
503490
}
504491

505-
let body = futures::stream::once(async { Result::<Bytes, Infallible>::Ok(Bytes::from_static(b"{}")) });
506-
let request = builder.body(HyperBody::wrap_stream(body)).unwrap();
492+
let body = Bytes::from_static(b"{}");
493+
494+
let request = builder.body(body).unwrap();
507495
let mut required_headers = SignedHeaderRequirements::new(
508496
vec!["Content-Type".into(), "Qwerty".into()],
509497
vec!["Foo".into(), "Bar".into(), "ETag".into()],
@@ -688,7 +676,7 @@ mod tests {
688676
.header("Host", "example.amazonaws.com")
689677
.header("X-Amz-Date", "20150830T123600Z")
690678
.header("Authorization", "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, Signature=444cab3690e122afc941d086f06cfbc82c1b4f5c553e32ac81e7629a82ff3831, SignedHeaders=host;x-amz-date")
691-
.body(HyperBody::empty())
679+
.body(())
692680
.unwrap();
693681

694682
assert!(sigv4_validate_request(
@@ -710,7 +698,7 @@ mod tests {
710698
.header("Host", "example.amazonaws.com")
711699
.header("X-Amz-Date", "20150830T123600Z")
712700
.header("Authorization", "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, Signature=b475de2c96e7bfdfe03bd784d948218730ef62f48ac8bb9f2922af9a44f8657c, SignedHeaders=host;x-amz-date")
713-
.body(HyperBody::empty())
701+
.body(())
714702
.unwrap();
715703

716704
assert!(sigv4_validate_request(

0 commit comments

Comments
 (0)