middleware icon indicating copy to clipboard operation
middleware copied to clipboard

CSRF cookie is not working for HTTP

Open misekm opened this issue 6 months ago • 0 comments

Cookie generated by CSRF middleware is containing attribute 'Secure', which means, that cookie can be transferred only by HTTPS. When using strict http client and using HTTP protocol (unsecured), cookie will not be send in following requests.

It would be good to check incoming request for type of protocol and set 'Secure' attribute based on that. Potentially event X-Forwarded-For headers.

In production it makes sense to use HTTPS, so this issue will not occur often. But for example for testing, there is no need for HTTPS at all and in such case this is an issue.

misekm avatar Aug 25 '24 15:08 misekm