You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered some strange behavior when using Dream.memory_sessions as middleware within a Dream.scope. Forms that contain injected CSRF tokens via Dream.csrf_tag do not seem to store these tokens in the sessions, per the logger:
dream.csrf WARN REQ 2 CSRF token not for this session
Confusingly, all works as expected if the Dream.memory_sessions middleware is replaced with Dream.cookie_sessions.
I've created a modified version of d-form to reproduce the bug:
There is a bug at how Dream handles middlewares in a scope. It creates its own instance of middlewares for each route. In our case, each of the routes:
Dream.get "/"
Dream.post "/"
will have their own memory_sessions middleware with their own hash table as a back-end storage. Therefore, sessions created on GET requests will never be found in session storage of POST requests. As a result, tokens created on GET and sent back with POST will never match to tokens created in session storage on server, because corresponding session will not be found in POST’s session storage.
I'll prepare PR with fix soon.
For now, you can use middleware for the entire server:
Hi!
I've encountered some strange behavior when using
Dream.memory_sessions
as middleware within aDream.scope
. Forms that contain injected CSRF tokens viaDream.csrf_tag
do not seem to store these tokens in the sessions, per the logger:Confusingly, all works as expected if the
Dream.memory_sessions
middleware is replaced withDream.cookie_sessions
.I've created a modified version of d-form to reproduce the bug:
I'm afraid I'm too new to the framework to tell whether this is a bug or mistake on my end. Hope this is enough info! Thanks!
The text was updated successfully, but these errors were encountered: