actix-session-surrealdb

Crates.ioactix-session-surrealdb
lib.rsactix-session-surrealdb
version
sourcesrc
created_at2023-05-10 18:46:28.114674
updated_at2024-11-28 15:54:47.215757
descriptionSurrealdb SessionStore for actix-session
homepage
repositoryhttps://github.com/ixhbinphoenix/actix-session-surrealdb
max_upload_size
id861531
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(ixhbinphoenix)

documentation

README

actix-session-surrealdb

A library for actix-session which implements the SessionStore trait for SurrealDB.

NOT AN OFFICIAL LIBRARY FROM actix!

Support

This library was built for a Project of mine, and as such, is only tested for my specific use-case. I will try to support other use-cases, so please open Issues for errors you encounter, but this is more "best-effort" support than full.

This library is not tested very well, so use at your own risk. You also probably shouldn't use this in your production, but I'm not your Boss so do as you wish.

Minimum Supported Rust Version (MSRV): 1.75

Example Usage

You can use the SurrealSessionStore similarly to the CookieSessionStore or RedisSessionStore, but you'll have to connect and check your database first

#[actix_web::main]
async fn main() -> io::Result<()> {
    let db = Surreal::new<Ws>("127.0.0.1:8000").await.unwrap();

    db.signin({
        user: "root",
        pass: "root",
    }).await.unwrap();
    
    db.use_ns("test").use_db("test").await.unwrap();

    let session_store = SurrealSessionStore::from_connection(db, "sessions");

    let key = Key::generate();

    HttpServer::new(move || {
        App::new()
            .wrap(
                SessionMiddleware::builder(session_store.clone(), key.clone())
                   .cookie_same_site(actix_web::cookie::SameSite::None)
                   .cookie_secure(true)
                   .cookie_http_only(true)
                   .session_lifecycle(
                        PersistentSession::default()
                            .session_ttl_policy(actix_session::config::TtlExtensionPolicy::OnStateChanges)
                            .session_ttl(Duration::days(7)),
                   )
                   .build()
            )
    })
    .bind(("127.0.0.1", "8080"))?
    .run()
    .await
}

License

This Project is licensed under the MIT License which can be found here.

Commit count: 29

cargo fmt