The following example is for a Blazor WebAssembly app. The process is similar for other types of apps, but the code is slightly different depending on how the dependency injection container is configured.
In the program.cs file, add the following dependencies:
C#Copy
using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Extensions.Compliance.Redaction;
The above packages allow you to then add the redaction service to the dependency injection container with this code:
C#Copy
builder.Services.AddRedaction();
Choose which redaction implementation to use for each type of classified data
The AddRedactor method can include a RedactorOptions parameter. The parameter allows you to specify which redaction implementation to use for each data taxonomy.
For example, the following code specifies that the HMACSHA256Redactor should be used for EUII data.
C#Copy
builder.Services.AddRedaction(configure =>
{
// Configure to use the HMAC redactor
configure.SetHmacRedactor(configureHmac =>
{
// This key should be fetched from keyvault or some other secure store.
configureHmac.Key = "thisisadummykeythatshouldbereplacedwithakeyfromakeystore";
// Some discriminator to differentiate between different deployments of a service.
configureHmac.KeyId = 1;
}, new DataClassificationSet(DataClassifications.EUIIDataClassification));
});
red hat certified specialist in server hardening malaysia
Leave a Reply