-
Notifications
You must be signed in to change notification settings - Fork 47
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
REVEL CSRF: Same origin mismatch. #83
Comments
Is something stripping out the Host -header? Logging c.Request.Header.Get("Host") gives me nothing. But firefox claims the header is set. |
I'm still getting this:
I prepared a test revel project: https://github.com/ptman/revel-csrf-test , please guide me to fix it |
One other thing with your test. The form value posted must be |
A -> B -> C sounds nonsensical. Why couldn't the landing page include a form that has csrf-protection? You don't need to have referer & token to show the form (GET), only to process the form (POST). |
Hi, sorry to butt in. I just tested the code on the development branch. The "request URL fixing" ( https://github.com/revel/modules/blob/develop/csrf/app/csrf.go#L66 ) that adds |
Hi @golddranks the issue you seem to be having is that the hostname is missing from the request, then it would compact in that manner, the missing hostname may be due to revel running behind a proxy. Is that your setup ? |
I have revel running inside a container locally and behind a load balancer in AWS. Both have the same behaviour: I tried to run revel directly without container on localhost, but it still behaves the same. |
Looking at the code (EDIT, here: https://github.com/revel/revel/blob/master/server_adapter_go.go#L241 ), I don't find that behaviour surprising: https://stackoverflow.com/questions/23151827/how-to-get-url-in-http-request So it seems that the current way of "fixing" the URL is broken. |
Updated PR #91 , specifically this section which should cover most cases where the hostname is unknown. @golddranks let me know if this is still an issue |
@notzippy Much better, thank you. @golddranks Does it work behind a proxy for you? |
Tests seem to be failing for me. And also running behind the proxy started by revel run.
|
Do I have to rewrite all tests in order to keep the csrf filter happy? https://github.com/ptman/revel-csrf-test/commit/f069d3d0d600e67f42927cc429462fff890f88a3 |
Maybe add helpers that take care of the csrf-specific bits during tests? |
Will create a new issue on that |
I'm not sure if it's because of running behind a proxy or not, but with some logging just after
modules/csrf/app/csrf.go
Line 58 in 03baf1b
Clearly the test will fail with those inputs:
Something isn't working. I see that the logic is a bit different from cbonello/revel-csrf
The text was updated successfully, but these errors were encountered: