1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # Session
//!
//! Database-backed HTTP session management.
//!
//! Sessions are stored in a SQLite table (`sessions`) and identified by a
//! signed, opaque cookie. The middleware handles the full request/response
//! lifecycle: reading the session token from the cookie on the request path,
//! loading and fingerprint-validating the session, running the handler, and
//! then flushing dirty data or touching the expiry timestamp before writing the
//! `Set-Cookie` header on the response path.
//!
//! Requires the **`session`** feature flag (transitively enables `db`).
//!
//! # Provides
//!
//! - [`SessionConfig`] — deserialised session configuration (TTL, cookie name, limits).
//! - [`Session`] — axum extractor; primary API for handlers.
//! - [`SessionData`] — snapshot of a session row returned from the database.
//! - [`SessionToken`] — opaque 32-byte random token; redacted in `Debug`/`Display`.
//! - [`Store`] — low-level SQLite store; use directly for background jobs.
//! - [`SessionLayer`] — Tower layer; apply to a `Router` to enable session support.
//! - [`layer`] — convenience constructor for [`SessionLayer`].
//! - [`device`] — user-agent parsing helpers for device classification.
//! - [`fingerprint`] — browser fingerprinting for session hijacking detection.
//! - [`meta`] — request metadata ([`meta::SessionMeta`]) and [`meta::header_str`] helper.
//!
//! # Quick start
//!
//! ```rust,no_run
//! use modo::session::{self, SessionConfig, Store};
//! use modo::cookie::{CookieConfig, key_from_config};
//! use modo::db::Database;
//!
//! async fn build_app(
//! db: Database,
//! session_cfg: SessionConfig,
//! cookie_cfg: CookieConfig,
//! ) -> modo::Result<axum::Router> {
//! let key = key_from_config(&cookie_cfg)?;
//! let store = Store::new(db, session_cfg);
//! let session_layer = session::layer(store, &cookie_cfg, &key);
//!
//! let router = axum::Router::new()
//! // .route(...)
//! .layer(session_layer);
//!
//! Ok(router)
//! }
//! ```
pub use SessionConfig;
pub use Session;
pub use SessionState;
pub use SessionLayer;
pub use layer;
pub use ;
pub use SessionToken;