Table of Contents

Class SecurityHeadersMiddleware

Namespace
Compendium.Adapters.AspNetCore.Security
Assembly
Compendium.Adapters.AspNetCore.dll

Middleware that adds security headers to HTTP responses. Implements OWASP security best practices.

public sealed class SecurityHeadersMiddleware
Inheritance
SecurityHeadersMiddleware
Inherited Members

Remarks

This middleware should be registered early in the pipeline to ensure headers are added to all responses, including error responses.

Constructors

SecurityHeadersMiddleware(RequestDelegate, IOptions<SecurityHeadersOptions>)

Initializes a new instance of the SecurityHeadersMiddleware class.

public SecurityHeadersMiddleware(RequestDelegate next, IOptions<SecurityHeadersOptions> options)

Parameters

next RequestDelegate

The next middleware in the pipeline.

options IOptions<SecurityHeadersOptions>

The security headers configuration options.

Methods

InvokeAsync(HttpContext)

Invokes the middleware to add security headers to the response.

public Task InvokeAsync(HttpContext context)

Parameters

context HttpContext

The HTTP context.

Returns

Task

A task representing the asynchronous operation.