https://github.com/eld/turbopump
Session middleware and driver for the Rocket web framework (https://rocket.rs)
https://github.com/eld/turbopump
cookies rocket rust security sessions web
Last synced: about 1 month ago
JSON representation
Session middleware and driver for the Rocket web framework (https://rocket.rs)
- Host: GitHub
- URL: https://github.com/eld/turbopump
- Owner: ELD
- Created: 2020-10-02T00:51:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-14T14:24:12.000Z (about 5 years ago)
- Last Synced: 2025-07-12T18:53:38.791Z (11 months ago)
- Topics: cookies, rocket, rust, security, sessions, web
- Language: Rust
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Turbopump
Primitives for stateful sessions in Rocket. Providing multiple drivers:
- Cookie
- Database
- Cache (i.e. Redis, etc)
- In-Memory
### What belongs in the session store?
- Checking for auth? No. Auth is separate and tied to the session data, but not part of the actual session management.
- Reading and writing the session source? Yes.
- What belongs in the session store?
- A unique identifier
- Plain data
- Session operations
- Start (implicit - onResponse?)
- Read (implicit - RequestGuard)
- Destroy (explicit? destroy entire cookie and all references to session)
- Clear (clear the data in the cookie)
### Blueprint
- SessionFairing
- Actual piece that's attached to the Rocket instance
- on_attach -> store a `SessionHandler` instance in Rocket's shared state
- on_response -> set the session cookie if it hasn't been set yet
- SessionStore
- Stores the actual session data (or proxies it to another store, i.e. Database, etc)
- Basic session operations
- load
- store
- clear
- destroy
- Session
- Actual type with a FromRequest impl
- Contains the data stored by the handler
- ```rust
#[derive(Serialize, Deserialize)]
struct Session {
session_id: SessionId,
data: HashMap
}
impl FromRequest for Session {...}
impl Default for Session {...}
```
### Supported versions
- Rocket 0.5 and beyond - async only