Middleware for adding Content Security Policy, HSTS, and HPKP security headers to ASP.NET Core applications.
Joonasw.AspNetCore.SecurityHeaders is a middleware library for ASP.NET Core that adds security headers like Content Security Policy (CSP), HTTP Strict Transport Security (HSTS), and HTTP Public Key Pinning (HPKP) to web applications. It helps developers mitigate common web vulnerabilities such as XSS, protocol downgrades, and MITM attacks by providing a fluent configuration API.
ASP.NET Core developers building web applications who need to implement security headers compliant with modern web security standards.
It offers a simple, integrated middleware approach with features like nonce generation and conditional header application, reducing the complexity of manually managing security headers in ASP.NET Core.
Middleware for adding security headers to an ASP.NET Core application.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers a declarative, fluent interface for setting up CSP, HSTS, and HPKP headers, reducing manual configuration complexity as demonstrated in the example code.
Generates unique nonces per request for inline scripts and styles, enabling secure usage without 'unsafe-inline' directives, with easy integration via Razor tag helpers.
Allows excluding headers for specific paths like API endpoints using callbacks such as OnSendingHeader, providing flexibility in deployment.
Includes report-only mode for CSP and HPKP, facilitating safe testing by logging violations without blocking resources, as shown in the configuration examples.
Features HTTP Public Key Pinning, which is deprecated in modern browsers due to risks like site lockouts and is being phased out in favor of alternatives like Certificate Transparency.
Nonce generation relies on Razor tag helpers, making it incompatible with other view engines or static front-end setups without additional workarounds.
Focuses only on CSP, HSTS, and HPKP, omitting other common security headers such as X-Content-Type-Options or Referrer-Policy, which may require separate middleware.