Skip to content
This repository has been archived by the owner on Jun 20, 2018. It is now read-only.

csrf errors #31

Open
rizumu opened this issue Dec 22, 2011 · 6 comments
Open

csrf errors #31

rizumu opened this issue Dec 22, 2011 · 6 comments

Comments

@rizumu
Copy link

rizumu commented Dec 22, 2011

Tried installing gargoyle 0.6.1 with nexus 0.2.3 and none of the ajax links work for managing switches, due to the standard csrf errors. 403 forbidden CSRF verification failed. Request aborted.

The recent nexus commits to use ajaxSetup are being called correctly, but something (I've no idea what) is not working with gargoyles provided templates and staticfiles.

@dcramer
Copy link
Collaborator

dcramer commented Dec 22, 2011

Can you check the requests and see if it's showing the X-CSRF (or whatever its labeled) header in them? Also see if it's setting the csrf cookie on the initial gargoyle page load.

@rizumu
Copy link
Author

rizumu commented Dec 22, 2011

The X-CSRFToken is set in the headers.

Django is setting the csrf cookie, however I am using a custom name:
CSRF_COOKIE_NAME = "comunidad_csrftoken"

@dcramer
Copy link
Collaborator

dcramer commented Dec 22, 2011

And it's sending the token header (with the ajax call) as the correct value of the cookie? Are you behind SSL?

@rizumu
Copy link
Author

rizumu commented Dec 23, 2011

hrmpf. Today the token header isn't being included so I can't check. No SSL atm, and I'm on localhost. Well, I'll revisit it next week.

@armisael
Copy link

Just to resurrect this issue: this happens when you set a custom CSRF_COOKIE_NAME.

In our websites we have the following configuration: default cookie name for production environment (csrftoken) and a custom value for staging and unstable environments (s_csrftoken and u_csrftoken respectively)

Gargoyle request:

Cookie:csrftoken=rm11CGoHiH4znZQ... u_csrftoken=Ychnso82YtOutx8ywmk...
X-CSRFToken:rm11CGoHiH4znZQ...

One of our (patched) requests:

Cookie:csrftoken=rm11CGoHiH4znZQ... u_csrftoken=Ychnso82YtOutx8ywmk...
X-CSRFToken:Ychnso82YtOutx8ywmk...

What we did is just to edit the code at https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax replacing the CSRF cookie name in var csrftoken = getCookie('csrftoken');

Hope this issue will be fixed soon, gargoyle is an essential part of our infrastructure, and not being able to use it properly in our testing environment is kinda problematic.

@martino
Copy link

martino commented Oct 29, 2012

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants