- Cookies only Store a Generated Session UUID and a Storable 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 and SQLx optional Databases out of the Box.
- Supports Memory Only usage. No need to use a persistant database.
- Supports Per Session SessionID cookie Encryption for enhanced Security.
- Supports SessionID renewal for enhanced Security.
- Optional Fastbloom key storage for reduced Database lookups during new UUID generation. Boosting Bandwidth.
Help
If you need help with this library or have suggestions please go to our Discord Group
Install
Axum Session uses tokio.
By Default Axum Session uses postgres-rustls so if you need tokio native TLS please add default-features = false
to your cargo include for Axum Session.
# Cargo.toml
[]
# Postgres + rustls
= { = "0.3.3", = [ "postgres-rustls"] }
Cargo Feature Flags
default: [postgres-rustls]
key-store: Enabled the optional key storage. Will increase ram usage based on Fastbloom settings.
sqlite-rustls: Sqlx 0.7.0 support for the self-contained SQLite database engine and rustls.
sqlite-native: Sqlx 0.7.0 support for the self-contained SQLite database engine and native-tls.
postgres-rustls: Sqlx 0.7.0 support for the Postgres database server and rustls.
postgres-native: Sqlx 0.7.0 support for the Postgres database server and native-tls.
mysql-rustls: Sqlx 0.7.0 support for the MySQL/MariaDB database server and rustls.
mysql-native: Sqlx 0.7.0 support for the MySQL/MariaDB database server and native-tls.
redis-db: redis 0.23.0 session support.
surrealdb-rocksdb: surrealdb 1.0.0-beta.9 support for rocksdb.
surrealdb-tikv : surrealdb 1.0.0-beta.9 support for tikv.
surrealdb-indxdb : surrealdb 1.0.0-beta.9 support for indxdb.
surrealdb-fdb-?_? : surrealdb 1.0.0-beta.9 support for fdb versions 5_1, 5_2, 6_0, 6_1, 6_2, 6_3, 7_0, 7_1. Replace ?_? with version.
surrealdb-mem : surrealdb 1.0.0-beta.9 support for mem.
Example
use ;
use SocketAddr;
use ;
use ;
async
async
async
To enable private cookies for confidentiality, integrity, and authenticity. When a Key is set it will automatically set the Cookie into an encypted Private cookie which both protects the cookies data from prying eye's it also ensures the authenticity of the cookie.
Example
use ;
use SocketAddr;
use ;
use ;
async
To use axum_session in non_persistant mode Set the client to None and import SessionNullPool. SessionNullPool is always loaded and can be used where you do not want to include any database within the build.
Example
use ;
use SocketAddr;
use ;
use ;
async
async
To use axum_session with session mode set as Storable.
Example
use ;
use SocketAddr;
use ;
use ;
async
//No need to set the sessions accepted or not with gdpr mode disabled
async
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.