python - How to disable Django's CSRF protection behind a proxy -


i need run django system (let's call alfred) behind proxy. both on same network. proxy use yuri vandermeer's django-httpproxy. (see page yvandermeer.net)

both systems running django version 1.2.4

both systems in same (closed) network , on same ip. have proxy running on port 8000 , alfred on port 1337. need log on alfred using /admin site, comes default django (and have enabled). working via port 1337, need access via port 8000.

when try it, alfred throwing 403 csrf error , telling me i'm acutally man-in-the-middle (- , alfred right when saying so).

i tried several things disable alfreds csrf protection:

  1. i commented out csrfviewmiddleware in settings.py in middleware_classes
  2. i created disable.py , added disablecsrf class middleware classes (actually tried each[!] position) mentioned on site (questions/1785772 )

    #disable.py class disablecsrf(object):     def process_request(self, request):         setattr(request, '_dont_enforce_csrf_checks', true)
  3. i created disable.py , added disablecsrf class middleware classes (again tried each position) mentioned in other post here: http://hi.baidu.com/ledzep2/blog/item/e6b1612e21884c5c4ec2267a.html

    #disable.py class disablecsrf(object):     def process_view(self, request, callback, callback_args, callback_kwargs):         setattr(request, '_dont_enforce_csrf_checks', true)
  4. i tried comment out csfr protection mechanism in django/middleware/csrf.py found relevant part around line 190 not around line 160 mentioned on site: questions/1650941/

none of things mentioned worked. 403 error when try log on via /admin

how can disable csrf protection on alfred? possible disable /admin ? i'd prefer if middleware mentioned in 2. , 3. , not commenting out in source in 4. if there middleware-way great.

thanks in advance! :)

you can use @csrf_exempt decorator on view functions disable csrf view.
see documentation


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -