Skip to content

Commit 25c5da7

Browse files
committed
docs: enhance security header documentation by removing content references and clarifying examples
1 parent 3aa7ab3 commit 25c5da7

4 files changed

Lines changed: 25 additions & 15 deletions

File tree

docs/configuration.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,28 @@ In this example, a custom HTTP header `X-Custom-Header` is added to the response
8888

8989
## Combining Presets with Customization
9090

91-
You can use one of the built-in presets as a starting point and then further customize specific headers to meet your security needs.
91+
You can use one of the built-in presets as a starting point and then further customize specific headers to meet your security needs. Every `Secure` instance exposes its configuration as a list of header builders via `headers_list`, so you can replace, reorder, or extend that list to adjust individual headers even after instantiation.
9292

9393
### Example: Customizing a Preset
9494

9595
```python
96-
from secure import Secure, Preset
96+
from secure import Preset, Secure, StrictTransportSecurity
9797

9898
secure_headers = Secure.from_preset(Preset.BASIC)
99-
secure_headers.hsts.max_age(63072000) # Override the default max-age value
99+
100+
secure_headers.headers_list = [
101+
header
102+
for header in secure_headers.headers_list
103+
if header.header_name != "Strict-Transport-Security"
104+
]
105+
secure_headers.headers_list.append(
106+
StrictTransportSecurity()
107+
.max_age(63072000)
108+
.include_subdomains()
109+
)
100110
```
101111

102-
This approach allows you to quickly set up basic security headers while customizing certain parameters to fit your application’s security posture.
112+
This replaces the preset’s `Strict-Transport-Security` builder with a custom one while keeping the remaining headers unchanged.
103113

104114
---
105115

docs/headers/cache_control.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
## Purpose
44

5-
`Cache-Control` is a comma-separated list of **directives** that control caching behavior for both **requests** and **responses**. Used correctly, it helps prevent sensitive data from being cached and improves performance for cacheable assets. :contentReference[oaicite:1]{index=1}
5+
`Cache-Control` is a comma-separated list of **directives** that control caching behavior for both **requests** and **responses**. Used correctly, it helps prevent sensitive data from being cached and improves performance for cacheable assets.
66

77
## Default behavior
88

99
If you create `CacheControl()` and do not add directives, it returns the library default value:
1010

11-
- **Default header value:** `no-store, max-age=0` :contentReference[oaicite:2]{index=2}
11+
- **Default header value:** `no-store, max-age=0`
1212

1313
This is a secure baseline intended to prevent storage of sensitive responses.
1414

docs/headers/cross-origin-resource-policy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
The `Cross-Origin-Resource-Policy` (CORP) response header lets a **resource owner** declare what sites/origins are allowed to load that resource.
66

7-
This header is commonly used to reduce cross-origin data leaks by controlling who can load your resources (images, scripts, etc.) and by blocking certain cross-origin/cross-site `no-cors` requests when the policy is more restrictive. :contentReference[oaicite:1]{index=1}
7+
This header is commonly used to reduce cross-origin data leaks by controlling who can load your resources (images, scripts, etc.) and by blocking certain cross-origin/cross-site `no-cors` requests when the policy is more restrictive.
88

99
## Best Practices
1010

11-
- **`same-origin`**: Strong default for sensitive resources; only allow loads from the same origin. :contentReference[oaicite:2]{index=2}
12-
- **`same-site`**: Useful when you need to share resources across subdomains on the same “site” but not with unrelated sites. :contentReference[oaicite:3]{index=3}
13-
- **`cross-origin`**: Most permissive; allow any origin to load the resource (use intentionally, not by accident). :contentReference[oaicite:4]{index=4}
11+
- **`same-origin`**: Strong default for sensitive resources; only allow loads from the same origin.
12+
- **`same-site`**: Useful when you need to share resources across subdomains on the same “site” but not with unrelated sites.
13+
- **`cross-origin`**: Most permissive; allow any origin to load the resource (use intentionally, not by accident).
1414

1515
## Configuration with `secure`
1616

docs/headers/x-permitted-cross-domain-policies.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
## Purpose
44

5-
`X-Permitted-Cross-Domain-Policies` is a **response header** that sets a _meta-policy_ controlling whether site resources can be accessed cross-origin by documents running in legacy web clients (for example, Adobe Acrobat or Microsoft Silverlight). :contentReference[oaicite:0]{index=0}
5+
`X-Permitted-Cross-Domain-Policies` is a **response header** that sets a _meta-policy_ controlling whether site resources can be accessed cross-origin by documents running in legacy web clients (for example, Adobe Acrobat or Microsoft Silverlight).
66

7-
Usage is less common today because Flash/Silverlight have been deprecated, but many security testing tools still check for `X-Permitted-Cross-Domain-Policies: none` to reduce the risk of an overly-permissive cross-domain policy being present accidentally or maliciously. :contentReference[oaicite:1]{index=1}
7+
Usage is less common today because Flash/Silverlight have been deprecated, but many security testing tools still check for `X-Permitted-Cross-Domain-Policies: none` to reduce the risk of an overly-permissive cross-domain policy being present accidentally or maliciously.
88

9-
> This documentation format mirrors the style used in the existing header docs (e.g., Cache-Control). :contentReference[oaicite:2]{index=2}
9+
> This documentation format mirrors the style used in the existing header docs (e.g., Cache-Control).
1010
1111
## Default behavior
1212

1313
If you create `XPermittedCrossDomainPolicies()` and do not set a policy, it returns the library default value:
1414

15-
- **Default header value:** `none` :contentReference[oaicite:3]{index=3}
15+
- **Default header value:** `none`
1616

17-
This is the least permissive option and is the most common secure setting when you do not need legacy cross-domain policy behavior. :contentReference[oaicite:4]{index=4}
17+
This is the least permissive option and is the most common secure setting when you do not need legacy cross-domain policy behavior.
1818

1919
## Using with `Secure`
2020

0 commit comments

Comments
 (0)