CSRF protection in subdomains

See this thread about signing the CSRF cookie to increase protection in subdomains: Signing the CSRF cookie

You can override Django’s CSRF middleware, specifically the methods _get_secret and _set_csrf_cookie to perform otherwise the same logic but instead use request.get_signed_cookie and response.set_signed_cookie respectively.

If you override Django’s CSRF middleware to add this additional protection, then you likely will have to override Django’s LoginView (if you are using it) since the built-in LoginView uses Django’s built-in csrf middleware on this line @method_decorator(csrf_protect)