-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tide sessions #646
tide sessions #646
Conversation
We should probably also provide a |
update: https://github.com/jbr/async-redis-session (not published yet) |
examples/sessions.rs
Outdated
tide::log::start(); | ||
let mut app = tide::new(); | ||
|
||
app.middleware(tide::sessions::SessionMiddleware::memory_store( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo show with cookie store instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think there's anything wrong with starting people out on the memory store, since its flaws are more obvious (losing data on server restart). we want to strongly encourage people not to use either of them, and i think the sled store will probably be the recommended choice for apps that don't already have an external db
src/sessions/middleware.rs
Outdated
/// set on the outbound response and signed with an HKDF key derived | ||
/// from the `secret` provided on creation of the SessionMiddleware. | ||
/// The configurable session store uses a SHA256 digest of the cookie | ||
/// value and stores the session along with a potential expiry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// value and stores the session along with a potential expiry. | |
/// value as an id and stores the session along with a potential expiry. |
a4bb48d
to
f1cbfa8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so incredibly good! One nit, but otherwise 💯
@Fishrock123 Have your concerns been addressed? This is otherwise ready to merge, but you still have a change request on this |
7b0a320
to
2090f07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good enough to go, anything more seems to be addressable after merge.
this is an initial implementation of a session middleware in tide, using a somewhat modified async-sessions crate. this is implemented as a
sessions
feature, which is enabled by default.this pr reuses some of the signed cookie behavior from the cookie crate without requiring the entire application use signed cookies. this is to ensure that all users of sessions have signed cookies regardless of the rest of their application settings.
closes: #9
blocked on:
http-rs/async-session#2Publishing async-session 2.0.0 (@yoshuawuyts)@Fishrock123 clarifying change requestrelated: #541
as part of exploring this approach, I've fully implemented these session stores: