MadEyeMatt.AspNetCore.SecurityHeaders 6.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package MadEyeMatt.AspNetCore.SecurityHeaders --version 6.0.0
NuGet\Install-Package MadEyeMatt.AspNetCore.SecurityHeaders -Version 6.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MadEyeMatt.AspNetCore.SecurityHeaders" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MadEyeMatt.AspNetCore.SecurityHeaders --version 6.0.0
#r "nuget: MadEyeMatt.AspNetCore.SecurityHeaders, 6.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MadEyeMatt.AspNetCore.SecurityHeaders as a Cake Addin
#addin nuget:?package=MadEyeMatt.AspNetCore.SecurityHeaders&version=6.0.0

// Install MadEyeMatt.AspNetCore.SecurityHeaders as a Cake Tool
#tool nuget:?package=MadEyeMatt.AspNetCore.SecurityHeaders&version=6.0.0

AspNetCore.SecurityHeaders

A middleware to configure and add security headers to HTTP responses.

Usage

To enable the middleware in your ASP.NET Core app, just call the UseSecurityHeaders extenion method on the WebApplication instance. This minimal configuration will write the headers with default values.

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
WebApplication app = builder.Build();
app.UseSecurityHeaders();
app.MapGet("/", () => "Hello World!");
app.Run();

The default configuration produces the following response headers.

Content-Security-Policy: default-src 'none';
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin

You can configure every header using the AddSecurityHeaders extension method on the IServiceCollection. If you f.e. don't want to write the X-XSS-Protection header, just disble it using the options like below.

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddSecurityHeaders(options =>
{
	options.XssProtection.WriteEnabled = false;
});
WebApplication app = builder.Build();
app.UseSecurityHeaders();
app.MapGet("/", () => "Hello World!");
app.Run();

All header are WriteEnabled = true by default. The Permissions-Policy will not be written, because the options of this header are defines as opt-in. If no directive is activated, the header will not be written. Youn can enable directives using the options like below.

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddSecurityHeaders(options =>
{
	options.PermissionsPolicy.Accelerometer.Value = AllowListValue.Self;
	options.PermissionsPolicy.Accelerometer.WriteEnabled = true;
});
WebApplication app = builder.Build();
app.UseSecurityHeaders();
app.MapGet("/", () => "Hello World!");
app.Run();

This will write the Permissions-Policy in addition to the default header.

Permissions-Policy: accelerometer=(self)
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated