Show HN: Secure.py – Simplify HTTP Security Headers for Python Web Apps
Hi HN,<p>I&#x27;m excited to share a major update to secure.py, a Python library designed to make adding essential HTTP security headers to web apps easier than ever. This release is a complete rewrite, leveraging modern Python 3.10+ features to enhance usability and performance.<p>Why secure.py?<p>Adding headers like Content Security Policy (CSP), HSTS, and X-Frame-Options is crucial for protecting web applications from attacks like XSS and clickjacking. However, managing these headers across different frameworks and ensuring adherence to best practices can be cumbersome. secure.py removes that friction by providing:<p>- Out-of-the-Box Security Presets: Apply BASIC or STRICT security configurations with a single line of code.<p>- Full Customization: Take control over headers like CSP, HSTS, X-Frame-Options, Referrer-Policy, and more to tailor security to your app&#x27;s needs.<p>- Multi-Framework Support: Works with popular frameworks including Flask, Django, FastAPI, Starlette, and more—both synchronous and asynchronous.<p>- Modern Pythonic Design: Utilizes Python 3.10+ features like structural pattern matching and improved type hinting for cleaner and more efficient code.<p>- No External Dependencies: Lightweight and easy to include in any project.<p>- Best Practice Compliance: Follows recommendations from the OWASP Secure Headers Project and MDN Web Docs for robust security.<p>Requirements:<p>- Python 3.10 or higher<p>If you&#x27;re tired of manually adding security headers and worrying about consistency, give secure.py a try. It&#x27;s open source and designed to help developers add the kind of security that every app should have by default.<p>GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;TypeError&#x2F;secure">https:&#x2F;&#x2F;github.com&#x2F;TypeError&#x2F;secure</a><p>I welcome any feedback, ideas for improvement, or contributions from the community!<p>Thanks for checking it out!