Update authentication to include JWT-cookie
Related to https://github.com/howtographql/howtographql/issues/550
JWT in local storage is not secure. I recommend updating the authentication page here: https://www.howtographql.com/graphql-python/4-authentication/ Discussed in more depth here, https://github.com/graphql-python/graphene-django/issues/593#issuecomment-474122054
The relevant points: adding the library https://github.com/flavors/django-graphql-jwt and the code:
from graphql_jwt.decorators import jwt_cookie
urlpatterns = [
path('graphql/', jwt_cookie(GraphQLView.as_view(graphiql=True))),
]
This creates a JWT token in a cookie named "JWT" allowing the browser to act as a go-between for secure authentication between js client/backend.
django-graphql-jwt then has decorators to provide security: https://django-graphql-jwt.domake.io/en/stable/decorators.html
In this way, a javascript front end can securely access a backend data without exposure to XSS (CORS/CSRF settings required).
Source: howtographql/howtographql