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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cerbi.AspNetCore.Governance" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cerbi.AspNetCore.Governance" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cerbi.AspNetCore.Governance" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cerbi.AspNetCore.Governance --version 1.0.0
                    
#r "nuget: Cerbi.AspNetCore.Governance, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cerbi.AspNetCore.Governance@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cerbi.AspNetCore.Governance&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cerbi.AspNetCore.Governance&version=1.0.0
                    
Install as a Cake Tool

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:

  1. Events are automatically sent to the CerbiShield Router
  2. Governance policies are enforced in real-time
  3. API usage is tracked and visualized in the Dashboard
  4. Compliance reports include all API activity

License

MIT License - see LICENSE file for details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.