Skip to content

Side-effect while avoiding storing anonymous users sessions #7

Description

@diegodelemos

Background:
As a performance improvement, inveniosoftware/invenio-accounts#292 introduces new logic to avoid storing session for anonymous users in Redis (or the configured backend).

Problem:
However, this creates a side-effect; in each request (get the page, JS, CSS etc..) the anonymous user gets a new session, see:

image
First request gets a session (already different to the existing one as the page was reloaded)
image
Second request sends the previously received session but gets a new one in responses
image
Previous to the last request sets a new session
image
The last request now sends as session cookie the one set by the previous request and yet another session is created

This produces:

If one omits the new factory to avoid storing sessions for anonymous users everything works as expected.


Guesses

  • We suspect that this is caused due to the final request including the latest received session while the form was loaded using a (Session bound CSRF?) that was generated with a different session.
  • Another guess would be that when it tries to match the CSRF, it gets the form/csrf/session from the request i.e the form submitted and then it tries to find this in the store provider(Redis, in memory)...but as long as we don't store the anonymous sessions that would return None and the comparison would fail..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions