8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
8db0179
There was an error while loading. Please reload this page.
A release-candidate for secure v2.0.0 focused on a cleaner public API, modern presets, first-class ASGI/WSGI middleware, and safer header application/validation across frameworks.
Preset.BALANCED
Secure.with_default_headers()
Secure.from_preset(Preset.BALANCED)
Preset.BASIC
Preset.STRICT
Secure.headers
ValueError
header_items()
deduplicate_headers()
validate_and_normalize_headers()
SecureASGIMiddleware
http.response.start
SecureWSGIMiddleware
start_response
secure.middleware
multi_ok
Secure
allowlist_headers(...)
raise
drop
warn
deduplicate_headers(...)
first
last
concat
COMMA_JOIN_OK
MULTI_OK
validate_and_normalize_headers(...)
(name, value)
DEFAULT_ALLOWED_HEADERS
OnInvalidPolicy
OnUnexpectedPolicy
DeduplicateAction
Cross-Origin-Resource-Policy
X-DNS-Prefetch-Control
X-Permitted-Cross-Domain-Policies
CODE_OF_CONDUCT.md
CONTRIBUTING.md
BALANCED
BASIC
STRICT
HeaderSetError
AttributeError
RuntimeError
Origin-Agent-Cluster
X-Download-Options
X-XSS-Protection: 0
response.headers.set(...)
pyproject.toml
with_default_headers()
See the migration guide: docs/migration.md.
docs/migration.md
Full Changelog: v1.0.1...v2.0.0rc1
813fb2d
This release focuses on improving the performance of the Secure.set_headers method by reducing redundant type checks. The changes optimize the efficiency when setting multiple headers, especially in frameworks that support both synchronous and asynchronous methods.
Secure.set_headers
Secure.set_headers_async
A big thank you to @davidwtbuxton for raising the issue and helping us improve the project.
To upgrade to v1.0.1, simply run:
pip install --upgrade secure
5a5d847
We’re excited to announce the release of secure.py v1.0.0! This is a major update that completely redesigns the library with modern Python support and significant improvements in usability, security, and performance.
secure.py
Full API Overhaul: The entire library has been redesigned for Python 3.10+ with a more Pythonic API, leveraging type hints and modern language features like union operators (|) and cached_property.
|
cached_property
Improved Framework Support: Enhanced integration for popular web frameworks like FastAPI, Flask, Django, Sanic, Starlette, and more, with improved support for asynchronous frameworks.
Middleware Examples: We've added middleware-based integration examples for supported frameworks, making it easier to apply security headers across your application.
Enhanced Security Defaults: Updated default security headers for stronger protection, including refined Content-Security-Policy (CSP) configurations with nonce and strict-dynamic directives.
nonce
strict-dynamic
Better Type Annotations: The entire codebase now includes better type hints and annotations for an improved developer experience.
API Redesign: The library has undergone a full API redesign, and some previous methods have been deprecated or refactored. Be sure to review the documentation before upgrading.
Python 3.10+ Required: This release drops support for older versions of Python. Ensure you are running Python 3.10 or later before upgrading.
Server
We look forward to your feedback! 🚀
ace5832
Breaking Changes
Changelog:
Feature-Policy
Permissions-Policy
8a551d5
Merry Christmas! 🎅
Feature.Values.All
Feature.Values.All_
SameSite.LAX
SameSite.STRICT
94d1c48
SecurePolicies
Expires
max-age
Cache-control
XXS
XXP