Cerbi.AspNetCore.Governance
1.0.0
dotnet add package Cerbi.AspNetCore.Governance --version 1.0.0
NuGet\Install-Package Cerbi.AspNetCore.Governance -Version 1.0.0
<PackageReference Include="Cerbi.AspNetCore.Governance" Version="1.0.0" />
<PackageVersion Include="Cerbi.AspNetCore.Governance" Version="1.0.0" />
<PackageReference Include="Cerbi.AspNetCore.Governance" />
paket add Cerbi.AspNetCore.Governance --version 1.0.0
#r "nuget: Cerbi.AspNetCore.Governance, 1.0.0"
#:package Cerbi.AspNetCore.Governance@1.0.0
#addin nuget:?package=Cerbi.AspNetCore.Governance&version=1.0.0
#tool nuget:?package=Cerbi.AspNetCore.Governance&version=1.0.0
Cerbi.AspNetCore.Governance
ASP.NET Core middleware for automatic API governance. Zero-config auto-detection with full override support. Emits GovernedEvent for every HTTP request through 3 channels — HttpContext.Items, ILogger.BeginScope, and ICerbiEventSink.
Features
- Zero-config auto-detection - Automatically detects API endpoints and parameters
- Triple-channel event emission - HttpContext.Items, ILogger scopes, and ICerbiEventSink
- Per-request overrides - Full control over governance behavior per request
- Built-in API signatures - Uses Cerbi.Signatures.Api for common API events
- Minimal performance impact - Designed for production use
- Full ASP.NET Core integration - Works with existing middleware pipeline
Quick Start
1. Install Package
dotnet add package Cerbi.AspNetCore.Governance
2. Add to Services
public void ConfigureServices(IServiceCollection services)
{
services.AddCerbiGovernance(options =>
{
options.AppName = "MyApi";
options.Environment = "Production";
});
}
3. Add Middleware
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCerbiGovernance();
// ... other middleware
}
Event Channels
The middleware emits events through three channels:
1. HttpContext.Items
var governedEvent = HttpContext.Items["CerbiGovernedEvent"] as GovernedEvent;
2. ILogger.BeginScope
// Automatically available in all log entries for the request
logger.LogInformation("Processing request"); // Will include governed event data
3. ICerbiEventSink
public class MyEventHandler : ICerbiEventSink
{
public Task HandleEventAsync(GovernedEvent governedEvent)
{
// Process the event (send to CerbiShield, store, etc.)
return Task.CompletedTask;
}
}
services.AddSingleton<ICerbiEventSink, MyEventHandler>();
Per-Request Overrides
[HttpGet("/users")]
public async Task<IActionResult> GetUsers()
{
// Override default behavior for this request
HttpContext.SetCerbiOverride(new CerbiRequestOverride
{
EventType = "UserListAccess",
AdditionalFields = new Dictionary<string, object>
{
["department"] = "HR",
["accessLevel"] = "Manager"
}
});
// ... your logic
}
Configuration Options
services.AddCerbiGovernance(options =>
{
options.AppName = "MyApi";
options.Environment = "Production";
options.AutoDetectApiEndpoints = true;
options.IncludeRequestBody = false;
options.IncludeResponseBody = false;
options.ExcludePaths = new[] { "/health", "/metrics" };
options.GovernanceProfile = "MyApiProfile";
});
Integration with Logger Plugins
This middleware works seamlessly with Cerbi logger plugins:
- Serilog: Use with
Cerbi.Serilog.GovernanceAnalyzer - NLog: Use with
Cerbi.NLog.GovernanceAnalyzer - Microsoft.Extensions.Logging: Built-in scope integration
The governed event data is automatically included in all log entries for the request.
CerbiShield Integration
When used with CerbiShield:
- Events are automatically sent to the CerbiShield Router
- Governance policies are enforced in real-time
- API usage is tracked and visualized in the Dashboard
- Compliance reports include all API activity
License
MIT License - see LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Cerbi.Governance.Schemas (>= 1.0.0)
- Cerbi.Signatures.Api (>= 1.0.0)
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 |
|---|---|---|
| 1.0.0 | 36 | 3/12/2026 |
v1.0.0: Initial release with 3-channel event emission, auto-detection chains, per-request overrides, and ICerbiEventSink for direct logger plugin integration.