Skip to content

Commit 6c63f0e

Browse files
committed
Rewrite v2 CHANGELOG with detailed breaking changes, migration notes, and structured additions
1 parent d23135a commit 6c63f0e

1 file changed

Lines changed: 64 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,78 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
This is the first stable v2 release. Version `2.0.0` was burned and should be skipped when tagging or publishing.
1515

16+
v2 focuses on a cleaner public API, a redesigned preset model, first-class ASGI/WSGI middleware, and stricter, safer header handling.
17+
1618
### Breaking Changes
1719

18-
- The `Secure` API now requires Python 3.10+ and uses the new builder-style header modules with full typing; this release replaces the previous legacy surface and removes the older cookie-centric helpers.
19-
20+
- `Secure.headers` is now strict and read-only
21+
- v1: `headers` was a cached `dict[str, str]` and silently collapsed duplicate names
22+
- v2: duplicate header names (case-insensitive) raise `ValueError`
23+
- use `header_items()` for multi-valued output or `deduplicate_headers()` to resolve duplicates
24+
25+
- Default headers have changed
26+
- `Secure.with_default_headers()` now maps to `Preset.BALANCED`
27+
- v1 default included `Cache-Control: no-store`; v2 does not
28+
- applications relying on v1 defaults should explicitly configure required headers
29+
30+
- Presets redesigned
31+
- new `Preset.BALANCED` (recommended default)
32+
- `Preset.BASIC` updated for Helmet.js parity and no longer matches v1 BASIC
33+
- `Preset.STRICT` no longer enables HSTS preload by default
34+
- cache behavior and header composition differ across presets compared to v1
35+
36+
- FastAPI / ASGI integration model changed in practice
37+
- v1 relied on per-response mutation (`set_headers` / `set_headers_async`)
38+
- v2 introduces middleware-based integration as the recommended approach
39+
2040
### Added
2141

22-
- Comprehensive validation pipeline helpers (`allowlist_headers`, `deduplicate_headers`, `validate_and_normalize_headers`) and typed presets for `Secure`.
23-
- New header builder coverage for modern headers (CSP, Permissions Policy, COEP, etc.) with deterministic outputs.
24-
- Async-safe `set_headers_async` support for both method-call and mapping-style response objects plus helper mocks and contract tests.
42+
- Middleware
43+
- `SecureASGIMiddleware`
44+
- `SecureWSGIMiddleware`
45+
- `secure.middleware` module
46+
47+
- Header pipeline helpers
48+
- `allowlist_headers(...)`
49+
- `deduplicate_headers(...)`
50+
- `validate_and_normalize_headers(...)`
51+
- `header_items()` for ordered `(name, value)` output
52+
53+
- New header builders and constants
54+
- `CrossOriginResourcePolicy`
55+
- `XDnsPrefetchControl`
56+
- `XPermittedCrossDomainPolicies`
57+
- `MULTI_OK`, `COMMA_JOIN_OK`, `DEFAULT_ALLOWED_HEADERS`
58+
- policy enums: `OnInvalidPolicy`, `OnUnexpectedPolicy`, `DeduplicateAction`
59+
60+
### Changed
61+
62+
- `Secure.with_default_headers()` now returns the balanced preset
63+
- Header handling is stricter and fails fast on invalid or duplicate configurations
64+
- Header normalization and validation are first-class operations
65+
- Response integration is more robust across sync and async frameworks
66+
- `headers_list` mutations are now reflected correctly (no stale cached state)
67+
- Documentation updated to emphasize middleware usage and preset selection
68+
69+
### Migration Notes
70+
71+
- Do not assume v1 defaults
72+
- compare emitted headers and explicitly configure any required behavior
73+
74+
- Audit any usage of `Secure.headers`
75+
- treat as read-only in v2
76+
- use `header_items()` or `deduplicate_headers()` when duplicates are possible
2577

26-
### Testing
78+
- Move to middleware for ASGI/WSGI apps
79+
- replace per-response `set_headers_async()` calls with `SecureASGIMiddleware` or `SecureWSGIMiddleware`
2780

28-
- Added full contract tests for the header builders along with end-to-end coverage for `Secure` usage and response integration.
81+
- Explicitly configure behavior that changed
82+
- add `Cache-Control` if you relied on v1 defaults
83+
- add HSTS preload manually if required
2984

30-
### Docs
85+
### Notes
3186

32-
- Expanded README with usage examples, advanced pipeline guidance, updated framework integration references, and v2 migration guidance.
87+
- Neither v1 nor v2 exposes `secure.__version__`; use package metadata for version checks
3388

3489
## [1.0.1] - 2024-10-18
3590

0 commit comments

Comments
 (0)