Skip to content

Ability to extract SessionKey #306

Description

@robjtede

Discussed in #305

Originally posted by miketwenty1 December 4, 2022
Goal: Prevent 1 user from having multiple active sessions.

I'm using actix-web redis session middleware.

.wrap(SessionMiddleware::new(
    RedisActorSessionStore::new(redis_conn.clone()),
    secret_key.clone(),
))

When a user does a login, I'll go ahead and insert some data into their session.

session.insert("userid", id).expect("id inserted");

Seemingly these key/values via the session.insert are inner key/values to the actual managed middleware session keys that are made automagically.

First question: How can I extract this middleware session id key that redis uses for the inserts/sessions?

My thought is I would go ahead and insert a the userid as a redis key with the value being the middleware redis session id so I could easily lookup and void any sessions that the user may have if logging in again. (seems hacky idk).

Second question: Is there a much easier/cleaner way of doing this while still getting the nice managed sessions from the redis middleware?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-sessionProject: actix-sessionC-featureCategory: new functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions