-
Notifications
You must be signed in to change notification settings - Fork 50
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
Session#regenerate
does not call SessionStore#destroy
#240
Comments
A quick and dirty workaround: let session = request.session;
await session.destroy();
await session.regenerate();
session = null; // just to make sure you don't use it or session = request.session |
This seems to have the potential to lead to a security problem. It seems that no PR has been created for a long time, but I think it should be addressed. Since express-session works in a similar way, it might not be a problem. |
To me, this feels very unexpected. Best-case, a stale session with nobody using it remains in the store. I'd personally prefer it to be destroyed by-default with an option to not destroy it, in case somebody has a different use-case. |
A PR would be welcomed. |
Prerequisites
Fastify version
4.26.2
Plugin version
10.7.0
Node.js version
20.11.1
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
5.15.150-1-MANJARO
Description
I am trying to regenerate a session in one of my routes to make sure whatever data is in there is reset and I would prefer to also get a new session id as I am essentially restarting the session.
But as far as I can see there is no way for me, without manually interacting with the SessionStore myself, to delete the old session id.
#regenerate
only generates a new session for me and stores it.Steps to Reproduce
Something like:
For easier understanding on what is happening in the store:
Expected Behavior
I am essentially generating a completely new session with different ID and data/content.
I'd expect the session to be automatically deleted from the store as it is no longer used/needed.
As far as I can see, there is also no good workaround for this as calling
await request.session.destroy();
before regenerating the session sets it tonull
causingTypeError: Cannot read properties of null (reading 'regenerate')
The text was updated successfully, but these errors were encountered: