Skip to content

Commit 66fbebf

Browse files
authored
Merge pull request #833 from jbr/async-session-3.0.0
update async-session to 3.0.0
2 parents d441ae0 + 4f49d89 commit 66fbebf

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ unstable = []
3434

3535
[dependencies]
3636
async-h1 = { version = "2.3.0", optional = true }
37-
async-session = { version = "2.0.1", optional = true }
37+
async-session = { version = "3.0", optional = true }
3838
async-sse = "4.0.1"
3939
async-std = { version = "1.6.5", features = ["unstable"] }
4040
async-trait = "0.1.41"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#![forbid(unsafe_code)]
5858
#![deny(missing_debug_implementations, nonstandard_style)]
5959
#![warn(missing_docs, unreachable_pub, future_incompatible, rust_2018_idioms)]
60+
#![allow(clippy::len_without_is_empty)]
6061
#![doc(test(attr(deny(warnings))))]
6162
#![doc(test(attr(allow(unused_extern_crates, unused_variables))))]
6263
#![doc(html_favicon_url = "https://yoshuawuyts.com/assets/http-rs/favicon.ico")]

src/listener/unix_listener.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,10 @@ impl<State> Display for UnixListener<State> {
161161
}
162162

163163
fn unix_socket_addr_to_string(result: io::Result<SocketAddr>) -> Option<String> {
164-
result.ok().and_then(|addr| {
165-
if let Some(pathname) = addr.as_pathname().and_then(|p| p.canonicalize().ok()) {
166-
Some(format!("http+unix://{}", pathname.display()))
167-
} else {
168-
None
169-
}
170-
})
164+
result
165+
.ok()
166+
.as_ref()
167+
.and_then(SocketAddr::as_pathname)
168+
.and_then(|p| p.canonicalize().ok())
169+
.map(|pathname| format!("http+unix://{}", pathname.display()))
171170
}

src/sessions/middleware.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ impl<Store: SessionStore> SessionMiddleware<Store> {
267267
}
268268

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

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

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

297297
// Perform the verification.
298-
let mut mac = Hmac::<Sha256>::new_varkey(&self.key.signing()).expect("good key");
298+
let mut mac = Hmac::<Sha256>::new_from_slice(&self.key.signing()).expect("good key");
299299
mac.update(value.as_bytes());
300300
mac.verify(&digest)
301301
.map(|_| value.to_string())

0 commit comments

Comments
 (0)