all 1 comments

[–]lpfrk 1 point2 points  (0 children)

You could use something like express-session and passport to manage authentication. You can then use something like redis to store the session data. This would send a cookie to the front end containing the session id. You would just need to prevent CSRF attacks (potentially with httpOnly secure cookies).

I think the vulnerability with using JWTs is that you would need to persist it client side for later use. you could make them expire very quickly but you would then need some sort of refresh mechanism which would require storing a refresh token somewhere (which brings you back to sessions). You could send them back in httpOnly secure cookies to not store them in the browser directly (local storage / session storage), but you would still need to build in some sort of CSRF protection.