Skip to content

Set RefreshToken as HttpOnly cookie on server response (login/register)  #73

@henrikwirth

Description

@henrikwirth

As mentioned in this post:
https://blog.hasura.io/best-practices-of-using-jwt-with-graphql

Persisting JWT token in localstorage (prone to XSS) < Persisting JWT token in an HttpOnly cookie (prone to CSRF, a little bit better for XSS) < Persisting refresh token in an HttpOnly cookie (safe from CSRF, a little bit better for XSS).

Note that while this method is not resilient to serious XSS attacks, coupled with the usual XSS mitigation techniques, an HttpOnly cookie is a recommended way persisting session related information. But by persisting our session indirectly via a refresh token, we prevent a direct CSRF vulnerability we would have had with a JWT token.

Note that the new SameSite cookie spec which is getting increased support in most browsers will make Cookie based approaches safe from CSRF attacks. It might not be a solution if your Auth and API servers are hosted on different domains, but it should work really well otherwise!

So therefore I believe, this would make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Discussioneffort: lowimpact: highunblocks new usecases, substantial improvement to existing feature, fixes a major bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions