actix / actix/actix-extras

Ability to extract SessionKey

オープン
#306 コメント 17 件 リアクション 4 件 担当者 1 名 @miketwenty1 が担当を希望しています GitHub で見る
A-session C-feature
主要言語
Rust
スター
889
フォーク
224
平均マージ
9時間 37分
マージ済み PR(30日)
20

説明

### Discussed in https://github.com/actix/actix-extras/discussions/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?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。