[GH-ISSUE #4379] [feature]: store user sessions in DB #1599

Closed
opened 2026-03-16 21:00:55 +03:00 by kerem · 12 comments
Owner

Originally created by @RaHehl on GitHub (Sep 26, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4379

Is there an existing issue for this?

  • I have searched the existing issues

Summary

We would like to use pod scaling, as far as I understand it would be necessary for all (api) pods to have the same session information, so the best solution would probably be to store the sessions in the database.

Maybe this can be easily solved: https://github.com/kleydon/prisma-session-store

Why should this be worked on?

Makes Hoppscotch more enterprise-ready

Originally created by @RaHehl on GitHub (Sep 26, 2024). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4379 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Summary We would like to use pod scaling, as far as I understand it would be necessary for all (api) pods to have the same session information, so the best solution would probably be to store the sessions in the database. Maybe this can be easily solved: https://github.com/kleydon/prisma-session-store ### Why should this be worked on? Makes Hoppscotch more enterprise-ready
kerem 2026-03-16 21:00:55 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@sah246ir commented on GitHub (Sep 29, 2024):

i am really interested in working on this issue.

<!-- gh-comment-id:2381206844 --> @sah246ir commented on GitHub (Sep 29, 2024): i am really interested in working on this issue.
Author
Owner

@yashs33244 commented on GitHub (Oct 7, 2024):

Hey there, if no one's working on this, can i be assigned this issue? Thank you!

<!-- gh-comment-id:2397583437 --> @yashs33244 commented on GitHub (Oct 7, 2024): Hey there, if no one's working on this, can i be assigned this issue? Thank you!
Author
Owner

@iRittikSharma commented on GitHub (Oct 8, 2024):

Hi @RaHehl I would like to work on this issue. Could You please assign it to me

<!-- gh-comment-id:2400141059 --> @iRittikSharma commented on GitHub (Oct 8, 2024): Hi @RaHehl I would like to work on this issue. Could You please assign it to me
Author
Owner

@RaHehl commented on GitHub (Oct 8, 2024):

Hi, I'm just the creator of the "issue". From what I understand, this should be assigned by someone from the Hopscotch team? @liyasthomas

<!-- gh-comment-id:2400157433 --> @RaHehl commented on GitHub (Oct 8, 2024): Hi, I'm just the creator of the "issue". From what I understand, this should be assigned by someone from the Hopscotch team? @liyasthomas
Author
Owner

@liyasthomas commented on GitHub (Oct 8, 2024):

Hi @iRittikSharma, do you have a proposal for the implementation. I'd love to discuss different possibilities of the implementation with Hoppscotch development team.

Feel free to open up a draft PR if you've already started working on it.

<!-- gh-comment-id:2400394731 --> @liyasthomas commented on GitHub (Oct 8, 2024): Hi @iRittikSharma, do you have a proposal for the implementation. I'd love to discuss different possibilities of the implementation with Hoppscotch development team. Feel free to open up a draft PR if you've already started working on it.
Author
Owner

@sah246ir commented on GitHub (Oct 9, 2024):

here's my workflow for the issue

  • firstly we can create a database table/collection to store the session id's and a few more parameters if required, this can be done from scratch on login or using the prisma-session-store library.
  • secondly we will store the session id as a secure http only cookie on the client side which will be attached to every request from the client.
  • thirdly we can create or modify existing middlewares to validate authentication.
  • lastly we can create or modify an endpoint to retrieve authentication status. the client will ping this route once on login to confirm the auth.

p.s @liyasthomas it would be better if you could assign it to someone so that there is only one person responsible for the task.

i would love to work on this too.

<!-- gh-comment-id:2401318592 --> @sah246ir commented on GitHub (Oct 9, 2024): here's my workflow for the issue - firstly we can create a database table/collection to store the session id's and a few more parameters if required, this can be done from scratch on login or using the prisma-session-store library. - secondly we will store the session id as a secure http only cookie on the client side which will be attached to every request from the client. - thirdly we can create or modify existing middlewares to validate authentication. - lastly we can create or modify an endpoint to retrieve authentication status. the client will ping this route once on login to confirm the auth. p.s @liyasthomas it would be better if you could assign it to someone so that there is only one person responsible for the task. i would love to work on this too.
Author
Owner

@liyasthomas commented on GitHub (Oct 9, 2024):

Looping in @AndrewBastin.

<!-- gh-comment-id:2401367518 --> @liyasthomas commented on GitHub (Oct 9, 2024): Looping in @AndrewBastin.
Author
Owner

@balub commented on GitHub (Oct 9, 2024):

Hey 👋 seems interesting, I can work on this.

<!-- gh-comment-id:2402539220 --> @balub commented on GitHub (Oct 9, 2024): Hey 👋 seems interesting, I can work on this.
Author
Owner

@balub commented on GitHub (Oct 9, 2024):

@RaHehl correct me if I am wrong here, but we essentially need to implement basic session storage now, where the session info is stored in our postgres?

<!-- gh-comment-id:2402605365 --> @balub commented on GitHub (Oct 9, 2024): @RaHehl correct me if I am wrong here, but we essentially need to implement basic session storage now, where the session info is stored in our postgres?
Author
Owner

@AndrewBastin commented on GitHub (Oct 9, 2024):

@RaHehl The self-hosted backend server uses JWTs to encode session information, so I am kinda confused by the session point you are raising here, the authorisation is done by reading the token, not across the DB or a session state that we maintain.

The challenge to pod scaling (horizontal scaling) implementation is actually related to mostly regarding two things.

  1. Data Subscriptions - The API server talks over GraphQL to listen to changes happening to workspaces, this is how realtime updates of collections and environments work on Hoppscotch. When you have multiple backend instances running, updates to the data could be accessing in one server and not the other.
  2. Configuration Changes - The admin dashboard allows you to set configuration updates that needs the server to restart. Notifying other instances to do that is a challenge as well.

Support for horizontal scaling is something we are working on and we will aim to ship it by the end of this month for the 2024.10 release cycle.

@RaHehl, can you confirm that you meant this issue to raise support for horizontal scaling (ability to have multiple instances of AIO/Backend containers to handle scaled loads ?) and not something else ?

<!-- gh-comment-id:2402800337 --> @AndrewBastin commented on GitHub (Oct 9, 2024): @RaHehl The self-hosted backend server uses JWTs to encode session information, so I am kinda confused by the session point you are raising here, the authorisation is done by reading the token, not across the DB or a session state that we maintain. The challenge to pod scaling (horizontal scaling) implementation is actually related to mostly regarding two things. 1. Data Subscriptions - The API server talks over GraphQL to listen to changes happening to workspaces, this is how realtime updates of collections and environments work on Hoppscotch. When you have multiple backend instances running, updates to the data could be accessing in one server and not the other. 2. Configuration Changes - The admin dashboard allows you to set configuration updates that needs the server to restart. Notifying other instances to do that is a challenge as well. Support for horizontal scaling is something we are working on and we will aim to ship it by the end of this month for the 2024.10 release cycle. @RaHehl, can you confirm that you meant this issue to raise support for horizontal scaling (ability to have multiple instances of AIO/Backend containers to handle scaled loads ?) and not something else ?
Author
Owner

@RaHehl commented on GitHub (Oct 14, 2024):

@AndrewBastin yes i can confirm it's for horizontal scaling, scaling loads and maybe version upgrades without downtime.

From a security perspective I would like to understand the jwt theme better

Am I seeing this correctly? The API issues a JWT token with the user ID and signs the whole thing. And when the client uses this signed token, is it the stateless authentication for the backend?

<!-- gh-comment-id:2410487173 --> @RaHehl commented on GitHub (Oct 14, 2024): @AndrewBastin yes i can confirm it's for horizontal scaling, scaling loads and maybe version upgrades without downtime. From a security perspective I would like to understand the jwt theme better Am I seeing this correctly? The API issues a JWT token with the user ID and signs the whole thing. And when the client uses this signed token, is it the stateless authentication for the backend?
Author
Owner

@AndrewBastin commented on GitHub (Oct 14, 2024):

is it the stateless authentication for the backend?

yes, the token is signed and contains all the info the backend needs to authenticate and authorize a request coming in, the tokens are also short lived and contain a TTL info attached with as well and lives as long as the duration ACCESS_TOKEN_VALIDITY environment variable specifies, after which the frontend has to request for a token refresh with the given refresh token, the refresh token is a plain value stored in the DB and using it the client can get new access tokens.

Anything more to clarify ?

yes i can confirm it's for horizontal scaling, scaling loads and maybe version upgrades without downtime.

If so, can we rephrase this issue to be specifically addressing horizontal scaling concerns ? For our plans for the release this month, we are planning on resolving most of the blockers to horizontal scaling here. We are generally skeptical about recommending version upgrades without downtime, not because there are technical blockers, but mostly because we want to still preserve our ability to make breaking changes to the database, atleast for a couple more releases, but hopefully we can provide that in the future.

<!-- gh-comment-id:2410533094 --> @AndrewBastin commented on GitHub (Oct 14, 2024): > is it the stateless authentication for the backend? yes, the token is signed and contains all the info the backend needs to authenticate and authorize a request coming in, the tokens are also short lived and contain a TTL info attached with as well and lives as long as the duration `ACCESS_TOKEN_VALIDITY` environment variable specifies, after which the frontend has to request for a token refresh with the given refresh token, the refresh token is a plain value stored in the DB and using it the client can get new access tokens. Anything more to clarify ? > yes i can confirm it's for horizontal scaling, scaling loads and maybe version upgrades without downtime. If so, can we rephrase this issue to be specifically addressing horizontal scaling concerns ? For our plans for the release this month, we are planning on resolving most of the blockers to horizontal scaling here. We are generally skeptical about recommending version upgrades without downtime, not because there are technical blockers, but mostly because we want to still preserve our ability to make breaking changes to the database, atleast for a couple more releases, but hopefully we can provide that in the future.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1599
No description provided.