Using React on the frontend with a RESTful API as backend and authorisation by JWT, how do we handle sessions? For example after login, I get a JWT token from REST. If I save it
Your server can set the JWT cookie directly as a response to the login request.
The server responds to POST /login
with Set-Cookie: JWT=xxxxxx
. That cookie is http only and therefore not vulnerable to XSS, and will be automatically included on all fetch requests from the client (as long as you use withCredentials: true
).
CSRF is mitigated as you mentioned, see OWASP for details.