`axum_session` provide's a Session management middleware that stores all session data within a MemoryStore internally. Optionally it can save data to a persistent database for long term storage. Uses Cookie or Header stored UUID's to sync back to the session store.
- Cookies or Header Store of Generated Session UUID and a Store Boolean. - Uses a DatabasePool Trait so you can implement your own Sub Storage Layer. - Convenient API for `Session` no need to mark as Read or Write making Usage Easier. - Uses `dashmap` for internal memory lookup and storage to achieve high throughput. - Uses Serdes for Data Serialization so it can store any Serdes supported type's into the Sessions data. - Supports Redis, SurrealDB, MongoDB and SQLx optional Databases out of the Box. - Supports Memory Only usage. No need to use a persistant database. - Supports Cookie and Header Signing for integrity, and authenticity. - Supports Database Session Data Encryption for confidentiality, integrity. - Supports SessionID renewal for enhanced Security. - Optional Fastbloom key storage for reduced Database lookups during new UUID generation. Boosting Bandwidth. - Optional Rest Mode that Disables Cookies and uses the Header values instead. - uses `#![forbid(unsafe_code)]` to ensure everything is implemented as safe rust. - has an `advanced` API to allow further control of a session. - uses IP address's and user agent to deter spoofing of signed cookies and headers. ## π¨ Help If you need help with this library or have suggestions please go to our [Discord Group](https://discord.gg/gVXNDwpS3Z) ## π¦ Install Axum Session uses [`tokio`]. to your cargo include for Axum Session. [`tokio`]: https://github.com/tokio-rs/tokio ```toml # Cargo.toml [dependencies] # Postgres + rustls axum_session = { version = "0.14.0" } ``` ## π± Cargo Feature Flags | Features | Description | | ----------------------------- | ---------------------------------------------------------------------------------------------- | | `advanced` | Enable functions allowing more direct control over the sessions. | | `rest_mode` | Disables Cookie Handlering In place of Header only usage for Rest API Requests and Responses. | | `key-store` | Enabled the optional key storage. Will increase ram usage based on Fastbloom settings. | | Database Crate | Persistent | Description | | ----------------------------------------------------------------------------------- | ---------- | ----------------------------------------------------------- | | [`axum_session_sqlx`](https://crates.io/crates/axum_session_sqlx) | Yes | Sqlx session store | | [`axum_session_surreal`](https://crates.io/crates/axum_session_surreal) | Yes | Surreal session store | | [`axum_session_mongo`](https://crates.io/crates/axum_session_mongo) | Yes | Mongo session store | | [`axum_session_redispool`](https://crates.io/crates/axum_session_redispool) | Yes | RedisPool session store | ## π Example Default Setup You can find examples within the [`Repository`](https://github.com/AscendingCreations/AxumSession/tree/main/examples) ```rust ignore use sqlx::{ConnectOptions, postgres::{PgPoolOptions, PgConnectOptions}}; use std::net::SocketAddr; use axum_session::{Session, SessionPgPool, SessionConfig, SessionStore, SessionLayer}; use axum::{ Router, routing::get, }; use tokio::net::TcpListener; #[tokio::main] async fn main() { let poll = connect_to_database().await.unwrap(); //This Defaults as normal Cookies. //To enable Private cookies for integrity, and authenticity please check the next Example. let session_config = SessionConfig::default() .with_table_name("sessions_table"); // create SessionStore and initiate the database tables let session_store = SessionStore::