π Overview
- 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
Sessionno need to mark as Read or Write making Usage Easier. - Uses
dashmapfor 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
advancedAPI 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
π¦ Install
Axum Session uses tokio.
to your cargo include for Axum Session.
# Cargo.toml
[]
# Postgres + rustls
= { = "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 |
Yes | Sqlx session store |
axum_session_surreal |
Yes | Surreal session store |
axum_session_mongo |
Yes | Mongo session store |
axum_session_redispool |
Yes | RedisPool session store |
π Example Default Setup
You can find examples within the Repository
use ;
use SocketAddr;
use ;
use ;
use TcpListener;
async
async
async
π Key Store Details
To enable and use fastbloom key storage for less database lookups.
Add the feature "key-store" to the crateβs features. This feature will increase the ram usage server side.
but will heavily improve the bandwidth limitations and reduce latency of returns from the server.
This is based on how much the filter_expected_elements and filter_false_positive_probability are set too.
The higher they are the more ram is used. You will also need to Enable the bloom filter in the config for it to be used. By default,
the use_bloom_filters is enabled and these config options exist whither or not the feature is enabled.
Please refer to with_filter_expected_elements and with_filter_false_positive_probability within the documents to set the options.
Otherwise stick with the default settings which should work in most situations. Just do note these options provide on how many False positives
could possibly occur when comparing a UUID to what currently exists, which means it will keep trying till it finds none that match.
Higher values decrease the chance of a false positive but increase ram usage.
π Session Login and Authentication via axum_session_auth
For user login, login caching and authentication please see axum_session_auth.