migrate to latest tower_sessions
This commit is contained in:
parent
94e26f8080
commit
30b75cc936
4 changed files with 279 additions and 292 deletions
542
Cargo.lock
generated
542
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
11
Cargo.toml
11
Cargo.toml
|
@ -14,7 +14,7 @@ askama = { version = "0.12", features = ["with-axum"] }
|
|||
askama_axum = "0.4"
|
||||
async-trait = "0.1"
|
||||
axum = { version = "0.7", features = ["macros"] }
|
||||
axum-login = "0.11"
|
||||
axum-login = "0.14"
|
||||
axum-macros = "0.4"
|
||||
chrono = { version = "0.4", default-features = false, features = ["std", "clock"] }
|
||||
clap = { version = "4", features = ["derive", "env", "unicode", "suggestions", "usage"] }
|
||||
|
@ -23,18 +23,19 @@ dirs = "5"
|
|||
http = "1"
|
||||
julid-rs = "1"
|
||||
justerror = "1"
|
||||
parse_duration = "2.1.1"
|
||||
parse_duration = "2"
|
||||
password-auth = "1"
|
||||
password-hash = { version = "0.5", features = ["std", "getrandom"] }
|
||||
rand = "0.8"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
sha256 = { version = "1.4.0", default-features = false }
|
||||
sha256 = { version = "1", default-features = false }
|
||||
sqlx = { version = "0.7", default-features = false, features = ["runtime-tokio", "sqlite", "tls-none", "migrate"] }
|
||||
thiserror = "1"
|
||||
tokio = { version = "1", features = ["full", "tracing"], default-features = false }
|
||||
tokio = { version = "1", features = ["rt-multi-thread", "signal", "tracing"], default-features = false }
|
||||
tower = { version = "0.4", features = ["util", "timeout"], default-features = false }
|
||||
tower-http = { version = "0.5", features = ["add-extension", "trace", "tracing", "fs"], default-features = false }
|
||||
tower-sessions = { version = "0.8", default-features = false, features = ["sqlite-store"] }
|
||||
tower-sessions = { version = "0.11", default-features = false }
|
||||
tower-sessions-sqlx-store = { version = "0.11.0", default-features = false, features = ["sqlite"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
unicode-segmentation = "1"
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
use async_trait::async_trait;
|
||||
use axum_login::{AuthUser, AuthnBackend, UserId};
|
||||
use axum_login::{
|
||||
tower_sessions::{cookie::time::Duration, Expiry, SessionManagerLayer},
|
||||
AuthUser, AuthnBackend, UserId,
|
||||
};
|
||||
use julid::Julid;
|
||||
use password_auth::verify_password;
|
||||
use sqlx::SqlitePool;
|
||||
use tower_sessions::{cookie::time::Duration, Expiry, SessionManagerLayer, SqliteStore};
|
||||
use tower_sessions_sqlx_store::SqliteStore;
|
||||
|
||||
use crate::User;
|
||||
|
||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -1,9 +1,8 @@
|
|||
use axum::{
|
||||
error_handling::HandleErrorLayer,
|
||||
middleware,
|
||||
routing::{get, post, IntoMakeService},
|
||||
BoxError,
|
||||
};
|
||||
use axum_login::AuthManagerLayerBuilder;
|
||||
use sqlx::SqlitePool;
|
||||
#[macro_use]
|
||||
extern crate justerror;
|
||||
|
@ -57,13 +56,9 @@ pub async fn app(db_pool: sqlx::SqlitePool) -> IntoMakeService<axum::Router> {
|
|||
};
|
||||
|
||||
let auth_layer = {
|
||||
let sessions = session_layer(db_pool.clone()).await;
|
||||
let session_layer = session_layer(db_pool.clone()).await;
|
||||
let store = AuthStore::new(db_pool.clone());
|
||||
tower::ServiceBuilder::new()
|
||||
.layer(HandleErrorLayer::new(|_: BoxError| async {
|
||||
http::StatusCode::BAD_REQUEST
|
||||
}))
|
||||
.layer(axum_login::AuthManagerLayerBuilder::new(store, sessions).build())
|
||||
AuthManagerLayerBuilder::new(store, session_layer).build()
|
||||
};
|
||||
|
||||
let assets_dir = std::env::current_dir().unwrap().join("assets");
|
||||
|
|
Loading…
Reference in a new issue