What you need
The middleware comes with the Enterprise Edition (it calls your Anonymizer server, with its central policy and its audit) and with the online service (it calls the API hosted by Sealforge, with your licence key).
| Your API | an ASP.NET Core project (Microsoft.NET.Sdk.Web), minimal APIs or controllers |
| The package | Sealforge.Anonymizer.AspNetCore, supplied with your licence: a private NuGet feed or a folder holding the .nupkg |
| The sign-in | internal server: an API key sfk_… created in the server's administration; online service: your licence key SF-… |
Set it up from the desktop app
In the app, open Settings → .NET and Java middleware, choose the folder of your repository or project, then Scan: the app finds your ASP.NET Core projects and their endpoints (MapGet, MapPost…, [HttpGet]… actions) by reading the code, without building or running anything.
You give the server, the strategy, and for each endpoint whether its request or its response is pseudonymized. Preview the changes shows every file and the lines added; Apply writes them, after a copy of each file.
.csproj | the package reference |
nuget.config | the feed you gave |
appsettings.json | the Sealforge:Anonymizer section |
Program.cs | AddSealforgeAnonymizer and UseSealforgeAnonymizer |
| endpoints | .AnonymizeRequestBody() / .AnonymizeResponseBody(), or the attributes on an action |
| user secrets | the API key or the licence key, never in the repository |
Or by hand: three lines
Add the package, then declare the middleware in Program.cs:
// Program.cs
builder.Services.AddSealforgeAnonymizer(builder.Configuration); // section Sealforge:Anonymizer
var app = builder.Build();
app.UseSealforgeAnonymizer();// appsettings.json
"Sealforge": { "Anonymizer": {
"ServerUrl": "https://anonymizer.corp.example",
"FailureMode": "Block"
} }The API key is read like the rest of the configuration (Sealforge:Anonymizer:ApiKey): keep it in user secrets, an environment variable or a secret store.
Choose the endpoints to protect
app.MapPost("/tickets", (Ticket t) => repository.Save(t))
.AnonymizeRequestBody(); // the endpoint, its logs and its database only see the pseudonymized body
app.MapGet("/customers/export", () => repository.All())
.AnonymizeResponseBody(); // the caller receives the data pseudonymizedOn a controller, the [AnonymizeRequestBody] and [AnonymizeResponseBody] attributes do the same.
Which body? The request, when the service itself must never hold the values (what it stores, logs or forwards). The response, when the service may hold them but not its caller (an export, a partner API, a front end). Both: a chat.
GET /customers/export
[ { "id": 1, "firstName": "[[FIRST_NAME_1]]", "lastName": "[[LAST_NAME_1]]", "email": "[[EMAIL_1]]" } ]In a JSON body, only string values are pseudonymized; the structure, numbers, booleans and property names are kept. FieldMode and Fields limit the processing to some properties, or leave some out.
Outgoing calls: an LLM or a partner API
builder.Services.AddHttpClient("llm", http => http.BaseAddress = new Uri("https://api.openai.com"))
.AddSealforgeAnonymization(outgoing => outgoing.Provider = "openai");The body sent is pseudonymized; in the answer, the tokens become the real values again. The LLM only sees tokens, your code gets a readable answer.
To pseudonymize from your own code (a message queue, a batch), inject ISealforgeAnonymizer: AnonymizeTextAsync, AnonymizeJsonAsync and their restores.
text/event-stream) are not restored: they keep their tokens. No value is lost, none leaks.Strategies and categories
Pseudonymization is either explicit (you list the categories and their strategy) or named (a strategy saved on the server, called by its name); never both.
"Sealforge": { "Anonymizer": {
"Strategy": "placeholder",
"Categories": { "FirstName": "", "LastName": "", "Email": "hash", "PhoneNumber": "redact" }
} }"Sealforge": { "Anonymizer": { "CentralStrategy": "rh-standard" } }With Categories, only the listed categories are pseudonymized; an empty value applies Strategy. A named strategy is a global strategy saved in the desktop app and published to the server's central policy.
Internal server or online service
By default the middleware calls your Enterprise Edition server. For the online service, set Target = Online, the address of the service and your licence key:
builder.Services.AddSealforgeAnonymizer(o =>
{
o.Target = AnonymizerTarget.Online;
o.ServerUrl = "https://anonymizer.sealforge.fr";
o.LicenseKey = builder.Configuration["Sealforge:LicenseKey"];
o.PseudonymKey = builder.Configuration["Sealforge:PseudonymKey"]; // 16+
o.CentralStrategy = "reversible";
});With the reversible strategy, values are encrypted inside the tokens with your key (PseudonymKey, 16 characters or more): the answer of an outgoing call is restored from the tokens themselves, and nothing is kept in between.
LicenseKeyProvider and PseudonymKeyProvider give the key of each call: one licence and one key per tenant of your application, read from a secret store.If the server does not answer
FailureMode = Block (the default): server unreachable, licence refused or a body larger than MaxBodyBytes, the request is refused (503 or 413) and an outgoing call throws AnonymizationUnavailableException. Nothing leaves in clear.
PassThrough sends the body as it is and logs an error: keep it for data allowed to leave.