~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to docs/ref/contrib/csrf.txt

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2013-11-07 15:33:49 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20131107153349-e31sc149l2szs3jb
Tags: 1.6-1
* New upstream version. Closes: #557474, #724637.
* python-django now also suggests the installation of ipython,
  bpython, python-django-doc, and libgdal1.
  Closes: #636511, #686333, #704203
* Set package maintainer to Debian Python Modules Team.
* Bump standards version to 3.9.5, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
384
384
    the middleware. Example::
385
385
 
386
386
        from django.views.decorators.csrf import csrf_exempt
 
387
        from django.http import HttpResponse
387
388
 
388
389
        @csrf_exempt
389
390
        def my_view(request):
410
411
 
411
412
.. function:: ensure_csrf_cookie(view)
412
413
 
413
 
    .. versionadded:: 1.4
414
 
 
415
414
    This decorator forces a view to send the CSRF cookie.
416
415
 
417
416
Scenarios
490
489
Settings
491
490
========
492
491
 
493
 
A number of settings can be used to control Django's CSRF behavior.
494
 
 
495
 
CSRF_COOKIE_DOMAIN
496
 
------------------
497
 
 
498
 
Default: ``None``
499
 
 
500
 
The domain to be used when setting the CSRF cookie.  This can be useful for
501
 
easily allowing cross-subdomain requests to be excluded from the normal cross
502
 
site request forgery protection.  It should be set to a string such as
503
 
``".example.com"`` to allow a POST request from a form on one subdomain to be
504
 
accepted by a view served from another subdomain.
505
 
 
506
 
Please note that, with or without use of this setting, this CSRF protection
507
 
mechanism is not safe against cross-subdomain attacks -- see `Limitations`_.
508
 
 
509
 
CSRF_COOKIE_NAME
510
 
----------------
511
 
 
512
 
Default: ``'csrftoken'``
513
 
 
514
 
The name of the cookie to use for the CSRF authentication token. This can be
515
 
whatever you want.
516
 
 
517
 
CSRF_COOKIE_PATH
518
 
----------------
519
 
 
520
 
.. versionadded:: 1.4
521
 
 
522
 
Default: ``'/'``
523
 
 
524
 
The path set on the CSRF cookie. This should either match the URL path of your
525
 
Django installation or be a parent of that path.
526
 
 
527
 
This is useful if you have multiple Django instances running under the same
528
 
hostname. They can use different cookie paths, and each instance will only see
529
 
its own CSRF cookie.
530
 
 
531
 
CSRF_COOKIE_SECURE
532
 
------------------
533
 
 
534
 
.. versionadded:: 1.4
535
 
 
536
 
Default: ``False``
537
 
 
538
 
Whether to use a secure cookie for the CSRF cookie. If this is set to ``True``,
539
 
the cookie will be marked as "secure," which means browsers may ensure that the
540
 
cookie is only sent under an HTTPS connection.
541
 
 
542
 
CSRF_FAILURE_VIEW
543
 
-----------------
544
 
 
545
 
Default: ``'django.views.csrf.csrf_failure'``
546
 
 
547
 
A dotted path to the view function to be used when an incoming request
548
 
is rejected by the CSRF protection.  The function should have this signature::
549
 
 
550
 
  def csrf_failure(request, reason="")
551
 
 
552
 
where ``reason`` is a short message (intended for developers or logging, not for
553
 
end users) indicating the reason the request was rejected.
 
492
A number of settings can be used to control Django's CSRF behavior:
 
493
 
 
494
* :setting:`CSRF_COOKIE_DOMAIN`
 
495
* :setting:`CSRF_COOKIE_HTTPONLY`
 
496
* :setting:`CSRF_COOKIE_NAME`
 
497
* :setting:`CSRF_COOKIE_PATH`
 
498
* :setting:`CSRF_COOKIE_SECURE`
 
499
* :setting:`CSRF_FAILURE_VIEW`