mirror of
https://github.com/django/django.git
synced 2025-11-01 20:31:40 +00:00
Fixed #19866 -- Added security logger and return 400 for SuspiciousOperation.
SuspiciousOperations have been differentiated into subclasses, and are now logged to a 'django.security.*' logger. SuspiciousOperations that reach django.core.handlers.base.BaseHandler will now return a 400 instead of a 500. Thanks to tiwoc for the report, and Carl Meyer and Donald Stufft for review.
This commit is contained in:
parent
36d47f72e3
commit
d228c1192e
38 changed files with 363 additions and 77 deletions
|
|
@ -231,3 +231,25 @@ same way you can for the 404 and 500 views by specifying a ``handler403`` in
|
|||
your URLconf::
|
||||
|
||||
handler403 = 'mysite.views.my_custom_permission_denied_view'
|
||||
|
||||
.. _http_bad_request_view:
|
||||
|
||||
The 400 (bad request) view
|
||||
--------------------------
|
||||
|
||||
When a :exc:`~django.core.exceptions.SuspiciousOperation` is raised in Django,
|
||||
the it may be handled by a component of Django (for example resetting the
|
||||
session data). If not specifically handled, Django will consider the current
|
||||
request a 'bad request' instead of a server error.
|
||||
|
||||
The view ``django.views.defaults.bad_request``, is otherwise very similar to
|
||||
the ``server_error`` view, but returns with the status code 400 indicating that
|
||||
the error condition was the result of a client operation.
|
||||
|
||||
Like the ``server_error`` view, the default ``bad_request`` should suffice for
|
||||
99% of Web applications, but if you want to override the view, you can specify
|
||||
``handler400`` in your URLconf, like so::
|
||||
|
||||
handler400 = 'mysite.views.my_custom_bad_request_view'
|
||||
|
||||
``bad_request`` views are also only used when :setting:`DEBUG` is ``False``.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue