Skip to content
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

Improvements to session management #439

Closed
fmartingr opened this issue Jun 23, 2022 · 0 comments · Fixed by #648
Closed

Improvements to session management #439

fmartingr opened this issue Jun 23, 2022 · 0 comments · Fixed by #648
Labels

Comments

@fmartingr
Copy link
Member

Currently sessions exist only in memory, that means, once you restart the service all logged in sessions will require login in again. Also there's a lot of duplicated code laying around managing this, both in the front-end and the back-end.

Ideally, all session related management should be backend only. The frontend only need to submit the form and either let the backend set the cookie or retrieve a JWT token and work with it.

Since the frontend is currently an SPA, and to ease working with the browser extension and allow other developers to easily integrate with the API I'm inclining towards the JWT approach.

The flow would be simple:

  • A /login endpoint that will check credentials and return the token, valid for a defined period of time (maybe 7d?)
  • A /refresh endpoint that will receive the JWT token and will refresh it's duration for another parametrized (with limits) period of time.

This will delegate to the backend the session generation but will let the clients how to use and work with it, where to refresh or where to ask for a login prompt again.

The only missing piece for backwards compatibility would be session invalidation. Using JWTs that is not possible, but at the moment I don't think that's required for Shiori (since it's not even multi user), but if we wanted to implement it we could easily store an ID set in the JWT payload and we could check for it in the database, caching it in memory for an hour or so. That way even if we invalidated a session the most time that session would be alive will be for an hour in a worst-case scenario.

@fmartingr fmartingr added type:enhancement New feature or request component:frontend The bug is in front-end component:backend tag:meta labels Jun 23, 2022
@fmartingr fmartingr added this to the 1.6.0 milestone Jun 23, 2022
@fmartingr fmartingr removed this from the 1.6.0 milestone Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant