Skip to content

Commit bf974f1

Browse files
committed
fix: update configuration guide to clarify default security headers and their purpose
1 parent d166640 commit bf974f1

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

docs/configuration.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@ This guide provides detailed information on how to configure `secure` beyond the
88

99
## Default Headers
1010

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:
1212

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.
20+
- **X-Content-Type-Options:** `nosniff` – blocks MIME sniffing attacks.
21+
- **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.
1724

1825
### Applying Default Headers
1926

20-
To quickly apply these default headers, use the following command:
27+
To quickly apply this configuration, use:
2128

2229
```python
2330
secure_headers = Secure.with_default_headers()

0 commit comments

Comments
 (0)