#`axum_sessions` not setting cookie

5 messages · Page 1 of 1 (latest)

wooden sentinel
#

I'm making the backend for a side project of mine where I need Google sign in through OIDC. The signing in part works, but when I go to store the session, it doesn't keep the cookie.
I configure axum_sessions as such

let session_store = MemoryStore::new();
    let mut session_secret = [0u8; 256];
    rand::thread_rng().fill(&mut session_secret);
    let session_layer = SessionLayer::new(session_store, &session_secret)
        .with_persistence_policy(PersistencePolicy::ChangedOnly)
        .with_cookie_domain("localhost:8080")
        .with_cookie_name("session")
        .with_cookie_path("/")
        .with_secure(false);

Then, in the OIDC callback, I do

if session.insert("email", email).is_err() {
        return (
            StatusCode::INTERNAL_SERVER_ERROR,
            "Failed to update session",
        )
            .into_response();
    }

    Redirect::temporary("/").into_response()

I see the set-cookie header in dev tools, but the cookie then just disappears into the ether, and I end up in an endless cycle of logging in. Anyone have an idea?

torn ocean
#

Do you need to set an expiry on the cookie maybe?

#

#870760546109116496 is also a good place to ask

wooden sentinel
#

Expiry didn't help, so I'll take a shot at tokio's channel for it

wooden sentinel
#

For some cursed reason, it was SameSite=Strict?