diff --git a/Cargo.toml b/Cargo.toml index d315739..abfcfcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,14 +62,14 @@ tower-service = "0.3.2" tower-sessions-core = { workspace = true } tower-sessions-memory-store = { workspace = true, optional = true } tracing = { version = "0.1.40", features = ["log"] } -tower-cookies = "0.10.0" +tower-cookies = "0.11.0" time = { version = "0.3.29", features = ["serde"] } [dev-dependencies] async-trait = "0.1.74" anyhow = "1" -axum = "0.7.1" -axum-core = "0.4.0" +axum = "0.8.1" +axum-core = "0.5.0" futures = { version = "0.3.28", default-features = false, features = [ "async-await", ] } @@ -84,7 +84,7 @@ time = "0.3.30" tokio = { version = "1.32.0", features = ["full"] } tokio-test = "0.4.3" tower = { version = "0.5.0", features = ["util"] } -tower-cookies = "0.10.0" +tower-cookies = "0.11.0" tower-sessions-core = { workspace = true, features = ["deletion-task"] } [[example]] diff --git a/examples/counter-extractor.rs b/examples/counter-extractor.rs index e55e12a..7b4a472 100644 --- a/examples/counter-extractor.rs +++ b/examples/counter-extractor.rs @@ -1,6 +1,5 @@ use std::net::SocketAddr; -use async_trait::async_trait; use axum::{extract::FromRequestParts, response::IntoResponse, routing::get, Router}; use http::request::Parts; use serde::{Deserialize, Serialize}; @@ -12,7 +11,6 @@ const COUNTER_KEY: &str = "counter"; #[derive(Default, Deserialize, Serialize)] struct Counter(usize); -#[async_trait] impl FromRequestParts for Counter where S: Send + Sync, diff --git a/examples/strongly-typed.rs b/examples/strongly-typed.rs index 46d02c0..37560db 100644 --- a/examples/strongly-typed.rs +++ b/examples/strongly-typed.rs @@ -1,6 +1,5 @@ use std::{fmt, net::SocketAddr}; -use async_trait::async_trait; use axum::{extract::FromRequestParts, response::IntoResponse, routing::get, Router}; use http::{request::Parts, StatusCode}; use serde::{Deserialize, Serialize}; @@ -67,7 +66,6 @@ impl fmt::Display for Guest { } } -#[async_trait] impl FromRequestParts for Guest where S: Send + Sync, diff --git a/src/lib.rs b/src/lib.rs index dcf4475..8e3a0bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,7 +136,6 @@ //! #[derive(Default, Deserialize, Serialize)] //! struct Counter(usize); //! -//! #[async_trait] //! impl FromRequestParts for Counter //! where //! S: Send + Sync, @@ -221,7 +220,6 @@ //! } //! } //! -//! #[async_trait] //! impl FromRequestParts for Guest //! where //! S: Send + Sync, diff --git a/src/service.rs b/src/service.rs index 2c573f8..23c4ba4 100644 --- a/src/service.rs +++ b/src/service.rs @@ -126,7 +126,7 @@ impl<'a> SessionConfig<'a> { } } -impl<'a> Default for SessionConfig<'a> { +impl Default for SessionConfig<'_> { fn default() -> Self { Self { name: "id".into(), /* See: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-id-name-fingerprinting */ @@ -547,9 +547,8 @@ mod tests { use tower::{ServiceBuilder, ServiceExt}; use tower_sessions_memory_store::MemoryStore; - use crate::session::{Id, Record}; - use super::*; + use crate::session::{Id, Record}; async fn handler(req: Request) -> anyhow::Result> { let session = req @@ -791,7 +790,7 @@ mod tests { let sid1 = get_session_id(&res1); let rec1 = get_record(&session_store, &sid1).await; let req2 = Request::builder() - .header(http::header::COOKIE, &format!("id={}", sid1)) + .header(http::header::COOKIE, format!("id={}", sid1)) .body(Body::empty())?; let res2 = svc.call(req2).await?; let sid2 = get_session_id(&res2); @@ -820,7 +819,7 @@ mod tests { let sid1 = get_session_id(&res1); let rec1 = get_record(&session_store, &sid1).await; let req2 = Request::builder() - .header(http::header::COOKIE, &format!("id={}", sid1)) + .header(http::header::COOKIE, format!("id={}", sid1)) .body(Body::empty())?; let res2 = svc.call(req2).await?; let sid2 = get_session_id(&res2); @@ -850,7 +849,7 @@ mod tests { let sid1 = get_session_id(&res1); let rec1 = get_record(&session_store, &sid1).await; let req2 = Request::builder() - .header(http::header::COOKIE, &format!("id={}", sid1)) + .header(http::header::COOKIE, format!("id={}", sid1)) .body(Body::empty())?; let res2 = svc.call(req2).await?; let sid2 = get_session_id(&res2); diff --git a/tower-sessions-core/Cargo.toml b/tower-sessions-core/Cargo.toml index 3516123..eb72190 100644 --- a/tower-sessions-core/Cargo.toml +++ b/tower-sessions-core/Cargo.toml @@ -15,7 +15,7 @@ deletion-task = ["tokio/time"] [dependencies] async-trait = { workspace = true } -axum-core = { version = "0.4", optional = true } +axum-core = { version = "0.5.0", optional = true } base64 = "0.22.0" futures = { version = "0.3.28", default-features = false, features = [ "async-await", diff --git a/tower-sessions-core/src/extract.rs b/tower-sessions-core/src/extract.rs index ee9d1aa..a9307c8 100644 --- a/tower-sessions-core/src/extract.rs +++ b/tower-sessions-core/src/extract.rs @@ -1,10 +1,8 @@ -use async_trait::async_trait; use axum_core::extract::FromRequestParts; use http::{request::Parts, StatusCode}; use crate::session::Session; -#[async_trait] impl FromRequestParts for Session where S: Sync + Send,