Expire authentication token upon app restart
MarcS1975 opened this issue · 5 comments
I logged into an existing Flatnotes application using my password. All fine and all my docs were shown.
Then I noteiced that restarting the container keeps me logged into the website. This shuld not happen.
Even deleting the container and the docker image and re-installing an updated Faltnotes image does not require me to log in again.
I think these are major security risks. Any change of the underlying system should autmooatically kick the user out and force re-login.
Hi @MarcS1975. I don't agree that this is a security risk. Why should a restart of the container be related to invalidating user sessions? Maybe you just restarted the server for maintenance. Surely you wouldn't want this to kick you out?
What's happening under the hood is that the login process generates a token. This token is only invalidated by the following events:
- The token expires. This is controlled by the
FLATNOTES_SESSION_EXPIRY_DAYS
environment variable, which defaults to 30 days. - The secret used to generate the token is changed. This is controlled by the
FLATNOTES_SECRET_KEY
environment variable.
So if you want to invalidate all existing sessions, simply update the secret key.
I hope this helps.
I understand that invalidating the token in these scenarios would, in some cases, enhance security. I'm sure there are many other things that could be done to enhance security. But I still don't agree that not doing so is a "major security risk".
Do you run your server with SSL directly exposed to the internet?