Skip to content
Myr

Re-order by semantic. Fix link on flask-talismand and re-word many concepts

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Lowell Abbott · committed by Lowell Abbott · parent ee7cb9d · Browse files · 1 file+33 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+33 added−26 removed

  • other:+33 added−26 removed

1 file+33 added−26 removed

modified:docs/security.rst+33 added-26 removed
107 unmodified lines
108Security Headers109----------------110111This section contains a list of headers supported by Flask.112To configure HTTPS and handle the headers listed below we suggest the package `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`. 112To configure HTTPS and handle the headers listed below we suggest the package `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_. 113114Content Security Policy (CSP)115-----------------------------114HTTP Strict Transport Security (HSTS)115-------------------------------------116117Enhance security and prevents common web vulnerabilities such as cross-site scripting and MITM related attacks.117Redirects http requests to https on all urls, preventing Man-in-the-middle (MITM) attacks.118119Example:120121.. sourcecode:: none122 123 Content-Security-Policy: default-src https:; script-src 'nonce-{random}'; object-src 'none'123 Strict-Transport-Security: max-age=<expire-time 124 Strict-Transport-Security: max-age=<expire-time>; includeSubDomains 125 Strict-Transport-Security: max-age=<expire-time>; preload 126125See also `Content Security Policy <https://csp.withgoogle.com/docs/index.html>`_.127See also `Strict Transport Security <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security>`_. 128127HTTP Strict Transport Security (HSTS)128-------------------------------------129HTTP Public Key Pinning (HPKP)130------------------------------131130Redirects http requests to https on all urls, preventing MITM attacks.132This enables your web server to authenticate with a client browser using a specific certificate key to prevent Man-in-the-middle (MITM) attacks.133134Example:135136.. sourcecode:: none135 136 Strict-Transport-Security: max-age=<expire-time 137 Strict-Transport-Security: max-age=<expire-time>; includeSubDomains 138 Strict-Transport-Security: max-age=<expire-time>; preload 137140See also `Strict Transport Security <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security>`_. 138 Public-Key-Pins: pin-sha256="base64=="; max-age=expireTime [; includeSubDomains][; report-uri="reportURI"] 139140See also `Public Key Pinning <https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning>`_.141142X-FRAME-OPTIONS (Clickjacking protection)142X-Frame-Options (Clickjacking protection)143-----------------------------------------144145Prevents the client from clicking page elements outside of the website, avoiding hijacking or UI redress attacks.146
7 unmodified lines
154155X-Content-Type-Options156----------------------157158Prevents XSS by blocking requests on clients and forcing them to read the content type instead of first opening it.158This header prevents Cross-site scripting (XSS) by blocking requests on clients and forcing them to first read and validate the content-type before reading any of the contents of the request.159160.. sourcecode:: none161 162 X-Content-Type-Options: nosniff163164See also `X-Content-Type-Options <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options>`_. 165166Cookie options167--------------166Content Security Policy (CSP)167-----------------------------168169For setting cookies on client-side storage.169Enhances security and prevents common web vulnerabilities such as cross-site scripting (XSS) and Man-in-the-middle (MITM) related attacks.170171Example:172173.. sourcecode:: none174 175 Set-Cookie: [cookie-name]=[cookie-value] 175 Content-Security-Policy: default-src https:; script-src 'nonce-{random}'; object-src 'none'176177See also `HTTP cookies <https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Secure_and_HttpOnly_cookies>`_ .177See also `Content Security Policy <https://csp.withgoogle.com/docs/index.html>`_.178179HTTP Public Key Pinning (HPKP)180------------------------------179Cookie options180--------------181182For associating clients with web servers through a certificate key and prevent MITM attacks.182While these headers are not directly security related, they have important options that may affect your flask application.183184- ``Secure`` limits your cookies to HTTPS traffic only.185- ``HttpOnly`` protects the contents of your cookie from being visible to XSS.186- ``SameSite`` ensures that cookies can only be requested from the same domain that created them but this feature is not yet fully supported across all browsers. 187188Example:189190.. sourcecode:: none191 192 Set-Cookie: [cookie-name]=[cookie-value] 193188 Public-Key-Pins: pin-sha256="base64=="; max-age=expireTime [; includeSubDomains][; report-uri="reportURI"] 194See also:195190See also `Public Key Pinning <https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning>`_.196- Mozilla guide to `HTTP cookies <https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Secure_and_HttpOnly_cookies>`_.197- `OWASP HTTP Only <https://www.owasp.org/index.php/HttpOnly>`_.