mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #26947 -- Added an option to enable the HSTS header preload directive.
This commit is contained in:
parent
c412aaca73
commit
3c2447dd13
7 changed files with 67 additions and 4 deletions
|
@ -226,6 +226,7 @@ enabled or disabled with a setting.
|
|||
* :setting:`SECURE_BROWSER_XSS_FILTER`
|
||||
* :setting:`SECURE_CONTENT_TYPE_NOSNIFF`
|
||||
* :setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS`
|
||||
* :setting:`SECURE_HSTS_PRELOAD`
|
||||
* :setting:`SECURE_HSTS_SECONDS`
|
||||
* :setting:`SECURE_REDIRECT_EXEMPT`
|
||||
* :setting:`SECURE_SSL_HOST`
|
||||
|
@ -260,6 +261,10 @@ to the ``Strict-Transport-Security`` header. This is recommended (assuming all
|
|||
subdomains are served exclusively using HTTPS), otherwise your site may still
|
||||
be vulnerable via an insecure connection to a subdomain.
|
||||
|
||||
If you wish to submit your site to the `browser preload list`_, set the
|
||||
:setting:`SECURE_HSTS_PRELOAD` setting to ``True``. That appends the
|
||||
``preload`` directive to the ``Strict-Transport-Security`` header.
|
||||
|
||||
.. warning::
|
||||
The HSTS policy applies to your entire domain, not just the URL of the
|
||||
response that you set the header on. Therefore, you should only use it if
|
||||
|
@ -277,6 +282,7 @@ be vulnerable via an insecure connection to a subdomain.
|
|||
you may need to set the :setting:`SECURE_PROXY_SSL_HEADER` setting.
|
||||
|
||||
.. _"Strict-Transport-Security" header: https://en.wikipedia.org/wiki/Strict_Transport_Security
|
||||
.. _browser preload list: https://hstspreload.appspot.com/
|
||||
|
||||
.. _x-content-type-options:
|
||||
|
||||
|
|
|
@ -2062,6 +2062,25 @@ non-zero value.
|
|||
:setting:`SECURE_HSTS_SECONDS`) break your site. Read the
|
||||
:ref:`http-strict-transport-security` documentation first.
|
||||
|
||||
.. setting:: SECURE_HSTS_PRELOAD
|
||||
|
||||
``SECURE_HSTS_PRELOAD``
|
||||
-----------------------
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
||||
Default: ``False``
|
||||
|
||||
If ``True``, the :class:`~django.middleware.security.SecurityMiddleware` adds
|
||||
the ``preload`` directive to the :ref:`http-strict-transport-security`
|
||||
header. It has no effect unless :setting:`SECURE_HSTS_SECONDS` is set to a
|
||||
non-zero value.
|
||||
|
||||
.. warning::
|
||||
Setting this incorrectly can irreversibly (for at least several months,
|
||||
depending on browser releases) break your site. Read the
|
||||
:ref:`http-strict-transport-security` documentation first.
|
||||
|
||||
.. setting:: SECURE_HSTS_SECONDS
|
||||
|
||||
``SECURE_HSTS_SECONDS``
|
||||
|
@ -3334,6 +3353,7 @@ HTTP
|
|||
* :setting:`SECURE_BROWSER_XSS_FILTER`
|
||||
* :setting:`SECURE_CONTENT_TYPE_NOSNIFF`
|
||||
* :setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS`
|
||||
* :setting:`SECURE_HSTS_PRELOAD`
|
||||
* :setting:`SECURE_HSTS_SECONDS`
|
||||
* :setting:`SECURE_PROXY_SSL_HEADER`
|
||||
* :setting:`SECURE_REDIRECT_EXEMPT`
|
||||
|
|
|
@ -229,6 +229,9 @@ Requests and Responses
|
|||
* :class:`~django.middleware.common.CommonMiddleware` now sets the
|
||||
``Content-Length`` response header for non-streaming responses.
|
||||
|
||||
* Added the :setting:`SECURE_HSTS_PRELOAD` setting to allow appending the
|
||||
``preload`` directive to the ``Strict-Transport-Security`` header.
|
||||
|
||||
Serialization
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -160,8 +160,9 @@ server, there are some additional steps you may need:
|
|||
to a particular site should always use HTTPS. Combined with redirecting
|
||||
requests over HTTP to HTTPS, this will ensure that connections always enjoy
|
||||
the added security of SSL provided one successful connection has occurred.
|
||||
HSTS may either be configured with :setting:`SECURE_HSTS_SECONDS` and
|
||||
:setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS` or on the Web server.
|
||||
HSTS may either be configured with :setting:`SECURE_HSTS_SECONDS`,
|
||||
:setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS`, and :setting:`SECURE_HSTS_PRELOAD`,
|
||||
or on the Web server.
|
||||
|
||||
.. _host-headers-virtual-hosting:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue