Microsoft.Extensions.Compliance.Redaction 11.0.0

Microsoft.Extensions.Compliance.Redaction

A redaction engine and canonical redactors.

Install the package

From the command-line:

dotnet add package Microsoft.Extensions.Compliance.Redaction

Or directly in the C# project file:

<ItemGroup>
  <PackageReference Include="Microsoft.Extensions.Compliance.Redaction" Version="[CURRENTVERSION]" />
</ItemGroup>

Usage Example

Registering the services

The services can be registered using one of the AddRedaction overloads:

public static IServiceCollection AddRedaction(this IServiceCollection services)
public static IServiceCollection AddRedaction(this IServiceCollection services, Action<IRedactionBuilder> configure)

Configuring a redactor

Redactors are fetched at runtime using an IRedactorProvider. You can choose to implement your own provider and register it inside the AddRedaction call, or alternatively you can just use the default provider. Redactors can be configured using one of these IRedactionBuilder extension methods:

// Using the default redactor provider:
builder.Services.AddRedaction(redactionBuilder =>
{
    // Assigns a redactor to use for a set of data classifications.
    redactionBuilder.SetRedactor<MyRedactor>(MySensitiveDataClassification);
    // Assigns a fallback redactor to use when processing classified data for which no specific redactor has been registered. 
    // The `ErasingRedactor` is the default fallback redactor. If no redactor is configured for a data classification then the data will be erased.
    redactionBuilder.SetFallbackRedactor<MyFallbackRedactor>();
});

// Using a custom redactor provider:
builder.Services.AddSingleton<IRedactorProvider, MyRedactorProvider>();
builder.Services.AddRedaction(redactionBuilder => { });

Configuring the HMAC redactor

The HMAC redactor can be configured using one these IRedactionBuilder extension methods:

public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, Action<HmacRedactorOptions> configure, params DataClassificationSet[] classifications)
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications)

The HmacRedactorOptions requires its KeyId and Key properties to be set. The HmacRedactor is still in the experimental phase, which means that the above two methods will show warning EXTEXP0002 notifying you that the HmacRedactor is not yet stable. In order to use it, you will need to either add <NoWarn>$(NoWarn);EXTEXP0002</NoWarn> to your project file or add #pragma warning disable EXTEXP0002 around the calls to SetHmacRedactor.

Feedback & Contributing

We welcome feedback and contributions in our GitHub repo.

Supported Platforms

This package includes .NET Framework compatible targets, but is not officially supported on .NET Framework.

Showing the top 20 packages that depend on Microsoft.Extensions.Compliance.Redaction.

Packages Downloads
Microsoft.Extensions.Http.Diagnostics
Telemetry support for HTTP Client.
1

Version Downloads Last updated
11.0.0 1 11/12/2026
10.11.0 0 10/14/2026
10.10.0 0 09/09/2026
10.9.0 0 08/11/2026
10.8.0 0 07/14/2026
10.7.0 0 06/09/2026
10.6.0 0 05/12/2026
10.5.0 0 04/15/2026
10.4.0 0 03/10/2026
10.3.0 0 02/10/2026
10.2.0 0 01/13/2026
10.1.0 0 12/09/2025
10.0.0 0 11/11/2025
9.10.0 0 10/14/2025
9.9.0 0 09/09/2025
9.8.0 0 08/12/2025
9.7.0 0 07/08/2025
9.6.0 0 06/10/2025
9.5.0 0 05/13/2025
9.4.0 0 04/08/2025
9.3.0 0 03/11/2025
9.2.0 0 02/11/2025
9.1.0 0 01/14/2025
9.0.0 0 11/12/2024
9.0.0-preview.9.24507.7 0 10/08/2024
9.0.0-preview.8.24460.1 0 09/10/2024
9.0.0-preview.7.24412.10 0 08/14/2024
9.0.0-preview.6.24353.1 0 07/10/2024
9.0.0-preview.5.24311.7 0 06/11/2024
9.0.0-preview.4.24271.2 0 05/21/2024
9.0.0-preview.3.24209.3 0 04/11/2024
9.0.0-preview.2.24157.4 0 03/12/2024
9.0.0-preview.1.24108.1 0 02/13/2024
8.10.0 0 10/08/2024
8.9.1 0 09/06/2024
8.9.0 1 11/12/2026
8.8.0 0 08/13/2024
8.7.0 0 07/10/2024
8.6.0 0 06/11/2024
8.5.0 0 05/14/2024
8.4.0 0 04/09/2024
8.3.0 0 03/12/2024
8.2.0 0 02/13/2024
8.1.0 0 01/09/2024
8.0.0 0 11/14/2023
8.0.0-rc.2.23510.2 0 10/10/2023
8.0.0-rc.1.23453.1 0 09/12/2023
8.0.0-preview.7.23407.5 0 08/08/2023
8.0.0-preview.6.23360.2 0 07/12/2023
8.0.0-preview.5.23308.3 0 06/14/2023
8.0.0-preview.4.23273.7 0 05/23/2023