-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default path can cause unexpected CSRF token rejections #144
Comments
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days. |
We ran into this recently too. Could we add something to the README which documents this gotcha? (We had to change the path to |
@greywolve already made a PR :D |
I don't think it's a good idea to make the default path |
Avoid CSRF token failures due to multiple cookies being set at different paths. gorilla/csrf#144
The default path for the CSRF cookie is the request path. This can lead to multiple instances of the CSRF cookie.
For example:
GET /foo/bar
-> sets cookie with path of/foo/bar
GET /foo
-> sets cookie with path of/foo
When a subsequent request is sent that matches both paths the CSRF token can be rejected. I'm not sure if it is sending both cookies or sending the wrong one. But the request is rejected. These errors can be quite confusing to diagnose.
I resolved this in my application by changing the path to
/
.Would it be a good idea to change the default path to
/
or at least to document this potential problem?The text was updated successfully, but these errors were encountered: