You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/configuration.md
+13-6Lines changed: 13 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,23 @@ This guide provides detailed information on how to configure `secure` beyond the
8
8
9
9
## Default Headers
10
10
11
-
By default, `secure` applies a set of widely-used security headers that provide a strong baseline of protection. These include:
11
+
`Secure.with_default_headers()` uses `Preset.BALANCED`, which configures a consistent, modern baseline. The defaults cover browser isolation, MIME safety, and legacy compatibility guards while keeping the header set lean:
12
12
13
-
-**Strict-Transport-Security (HSTS)**: Ensures that browsers only connect to your site over HTTPS.
14
-
-**X-Frame-Options**: Protects against clickjacking attacks by controlling whether your site can be embedded in an iframe.
15
-
-**X-Content-Type-Options**: Prevents browsers from MIME-sniffing a response away from the declared `Content-Type`.
16
-
-**Content-Security-Policy (CSP)**: Mitigates Cross-Site Scripting (XSS) and data injection attacks by defining allowed content sources.
13
+
-**Cross-Origin-Opener-Policy:**`same-origin` – isolates the browsing context to prevent exploitation of shared global objects.
14
+
-**Cross-Origin-Resource-Policy:**`same-origin` – prevents cross-origin resources from being retrieved unless explicitly permitted.
15
+
-**Content-Security-Policy:**`default-src 'self'; base-uri 'self'; font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; upgrade-insecure-requests` – a conservative, CSP-first profile with no inline scripts and forced HTTPS upgrades.
16
+
-**Strict-Transport-Security (HSTS):**`max-age=31536000; includeSubDomains` – enforces HTTPS for browsers for one year.
17
+
-**Permissions-Policy:**`geolocation=(), microphone=(), camera=()` – disables a few sensitive browser features by default.
18
+
-**Referrer-Policy:**`strict-origin-when-cross-origin` – balances privacy and analytics by trimming cross-origin referrer data.
19
+
-**Server:** empty string – hides the underlying server software.
-**X-Frame-Options:**`SAMEORIGIN` – prevents framing by other origins.
22
+
23
+
Balanced intentionally skips `Cache-Control` and the older compatibility headers (`X-Permitted-Cross-Domain-Policies`, `X-DNS-Prefetch-Control`, `Origin-Agent-Cluster`, `X-Download-Options`, `X-XSS-Protection`), but you can add them manually when your deployment still depends on them.
17
24
18
25
### Applying Default Headers
19
26
20
-
To quickly apply these default headers, use the following command:
0 commit comments