Skip to content

Commit

Permalink
Merge pull request #833 from jbr/async-session-3.0.0
Browse files Browse the repository at this point in the history
update async-session to 3.0.0
  • Loading branch information
jbr authored Jun 1, 2021
2 parents d441ae0 + 4f49d89 commit 66fbebf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ unstable = []

[dependencies]
async-h1 = { version = "2.3.0", optional = true }
async-session = { version = "2.0.1", optional = true }
async-session = { version = "3.0", optional = true }
async-sse = "4.0.1"
async-std = { version = "1.6.5", features = ["unstable"] }
async-trait = "0.1.41"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#![forbid(unsafe_code)]
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, unreachable_pub, future_incompatible, rust_2018_idioms)]
#![allow(clippy::len_without_is_empty)]
#![doc(test(attr(deny(warnings))))]
#![doc(test(attr(allow(unused_extern_crates, unused_variables))))]
#![doc(html_favicon_url = "https://yoshuawuyts.com/assets/http-rs/favicon.ico")]
Expand Down
13 changes: 6 additions & 7 deletions src/listener/unix_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,10 @@ impl<State> Display for UnixListener<State> {
}

fn unix_socket_addr_to_string(result: io::Result<SocketAddr>) -> Option<String> {
result.ok().and_then(|addr| {
if let Some(pathname) = addr.as_pathname().and_then(|p| p.canonicalize().ok()) {
Some(format!("http+unix://{}", pathname.display()))
} else {
None
}
})
result
.ok()
.as_ref()
.and_then(SocketAddr::as_pathname)
.and_then(|p| p.canonicalize().ok())
.map(|pathname| format!("http+unix://{}", pathname.display()))
}
8 changes: 4 additions & 4 deletions src/sessions/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ impl<Store: SessionStore> SessionMiddleware<Store> {
}

// the following is reused verbatim from
// https://github.com/SergioBenitez/cookie-rs/blob/master/src/secure/signed.rs#L33-L43
// https://github.com/SergioBenitez/cookie-rs/blob/master/src/secure/signed.rs#L37-46
/// Signs the cookie's value providing integrity and authenticity.
fn sign_cookie(&self, cookie: &mut Cookie<'_>) {
// Compute HMAC-SHA256 of the cookie's value.
let mut mac = Hmac::<Sha256>::new_varkey(&self.key.signing()).expect("good key");
let mut mac = Hmac::<Sha256>::new_from_slice(&self.key.signing()).expect("good key");
mac.update(cookie.value().as_bytes());

// Cookie's new value is [MAC | original-value].
Expand All @@ -281,7 +281,7 @@ impl<Store: SessionStore> SessionMiddleware<Store> {
}

// the following is reused verbatim from
// https://github.com/SergioBenitez/cookie-rs/blob/master/src/secure/signed.rs#L45-L63
// https://github.com/SergioBenitez/cookie-rs/blob/master/src/secure/signed.rs#L51-L66
/// Given a signed value `str` where the signature is prepended to `value`,
/// verifies the signed value and returns it. If there's a problem, returns
/// an `Err` with a string describing the issue.
Expand All @@ -295,7 +295,7 @@ impl<Store: SessionStore> SessionMiddleware<Store> {
let digest = base64::decode(digest_str).map_err(|_| "bad base64 digest")?;

// Perform the verification.
let mut mac = Hmac::<Sha256>::new_varkey(&self.key.signing()).expect("good key");
let mut mac = Hmac::<Sha256>::new_from_slice(&self.key.signing()).expect("good key");
mac.update(value.as_bytes());
mac.verify(&digest)
.map(|_| value.to_string())
Expand Down

0 comments on commit 66fbebf

Please sign in to comment.