Preamble / TL;DR
I've got a dumb API using the PassportJS JWT strategy that I'd like to add sessions to for the purpose of having user isolation in certain areas, a requirement for some enhancements.
The entire system is comprised of a MySQL DB, NodeJS + ExpressJS (with PassportJS) backend and an Angular 2 frontend.
Further Information
I've had an issue with implementing sessions in my application, and experienced the same issues as seen in this Github Issue.
My frontend doesn't seem to handle the session id stored in the session cookie with the key 'connect.sid', even though a user can be correctly authenticated initially and get their JWT. The session cookie does however get used when bypassing the frontend and using POSTMAN to send the requests.
The primary symptoms of the issue I'm experiencing are:
- The session cookie is not created when using the Angular2 frontend. Sending the requests using POSTMAN seem to have the cookies created.
- The req.isAuthenticated() call is always false as a result (unless using POSTMAN)
I've now deduced it must be an issue with communication/handling of requests/responses between the front/backend.
I've spent the last couple days running through other issues like:
- Ordering/checking use statements: here, here
- Adding the respective headers to responses on the front and backend: here
And a couple others. I do however draw the following questions from this:
Question(s)
- Is it even correct implementing sessions with a JWT strategy, knowing the two should be exclusive from one another?
- If not, what would you recommend be done in this scenario?