Muonroi.AspNetCore 1.0.0-alpha.16

This is a prerelease version of Muonroi.AspNetCore.
dotnet add package Muonroi.AspNetCore --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.AspNetCore -Version 1.0.0-alpha.16
                    
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="Muonroi.AspNetCore" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.AspNetCore" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.AspNetCore" />
                    
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 Muonroi.AspNetCore --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.AspNetCore, 1.0.0-alpha.16"
                    
#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 Muonroi.AspNetCore@1.0.0-alpha.16
                    
#: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=Muonroi.AspNetCore&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.AspNetCore&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.AspNetCore

ASP.NET Core integration layer for the Muonroi Building Block: versioned API hosting, JWT bearer auth, license enforcement, CORS, causal-chain propagation, and startup diagnostics — wired up with a handful of extension calls.

NuGet License: Apache 2.0

Muonroi.AspNetCore is the hosting glue that connects the Muonroi core packages (Muonroi.Core, Muonroi.Tenancy.*, Muonroi.Data.EntityFrameworkCore, Muonroi.Mediator, Muonroi.Governance, and others) to an ASP.NET Core application. It provides opinionated DI registration helpers, a standardized middleware pipeline, attribute-based permission enforcement, and a pluggable startup diagnostics system that blocks misconfigured apps before they accept traffic.

Installation

dotnet add package Muonroi.AspNetCore --prerelease

Quick Start

The minimal setup for a versioned, documented API:

using Muonroi.AspNetCore.Extensions;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Registers API versioning (default v1.0), SwaggerGen, and health checks.
builder.Services.AddBaseApi();

builder.Services.AddControllers();

WebApplication app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();
app.MapControllers();
app.MapGet("/health", () => Results.Ok(new { status = "Healthy" }));

app.Run();

For a full infrastructure setup (JWT, EF, tenancy, CORS, mediator, validation):

using Muonroi.AspNetCore.Extensions;
using Muonroi.AspNetCore.Cors;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Wires API versioning, controllers, FluentValidation, license protection,
// multi-level caching, tenant context, quota management, and policy decisions.
// Requires LicenseConfigs:ProjectSeed (16+ chars) in appsettings.
builder.Services.AddInfrastructure(
    builder.Configuration,
    assemblies: typeof(Program).Assembly);

// CORS policy read from "MAllowDomains" config key (comma-separated origins).
builder.Services.AddCors(builder.Configuration);

// JWT bearer authentication (HMAC or RSA, driven by TokenConfigs in appsettings).
builder.Services.AddValidateBearerToken(builder.Configuration);

// Auth + permission services (requires a DbContext that extends MDbContext).
builder.Services.AddAuthServices<MyDbContext, MyPermissionEnum>();

// Autofac service provider (mediator + auth context modules).
builder.AddAutofacConfiguration();

// Startup diagnostics: blocks boot on critical misconfiguration.
builder.Services.AddMuonroiDiagnostics();

WebApplication app = builder.Build();

// License enforcement, exception handling, cookie auth, quota enforcement.
app.UseDefaultMiddleware();
app.UseMuonroiDiagnostics();
app.ConfigureEndpoints();   // Swagger, MapControllers, health endpoints

app.Run();

Features

  • AddBaseApi() — API versioning (Asp.Versioning, default v1.0 with ReportApiVersions), SwaggerGen, and health checks in one call.
  • AddInfrastructure() — full-stack registration: controllers with GlobalExceptionFilter + RequestLoggingFilter, LowerCaseControllerNameConvention, FluentValidation, license protection, multi-level caching, tenant context, quota management, and policy-decision wiring.
  • AddValidateBearerToken() — JWT bearer auth supporting HMAC (SymmetricSecretKey) or RSA (UseRsa=true + PEM key); per-tenant signing keys; lazy IssuerSigningKeyResolver.
  • AddAuthServices<TDbContext, TPermission>() — registers IAuthService<TPermission, TDbContext> and IPermissionService<TPermission>.
  • AddPermissionFilter<TPermission>() — global MVC PermissionFilter<TPermission> for attribute-driven access control.
  • UseDefaultMiddleware() — pipeline order: TenantContextMiddleware (when tenancy enabled) → QuotaEnforcementMiddlewareLicenseMiddlewareMExceptionMiddlewareMCookieAuthMiddleware.
  • ConfigureEndpoints() — configures Swagger UI, MapControllers, /health, /health/live, /health/ready, /grpc/ready, /grpc/live, and a root redirect to /swagger.
  • AddCors() — CORS policy from configuration (MAllowDomains config key), with the standard Muonroi header and method set.
  • AddMuonroiCausalChain() + MCausalChainDelegatingHandler — propagates correlation/causation headers across outbound HttpClient calls.
  • AddMuonroiDiagnostics() / UseMuonroiDiagnostics() — 6 built-in startup checks (dependency graph, configuration, connectivity, ecosystem registry, license status, tenant config); Critical failures throw and block startup.
  • AddApplication() — lightweight alternative: mediator, object mapper, IMDateTimeService, ISystemExecutionContextAccessor, camelCase JSON.
  • SwaggerConfig() — Swagger doc with Bearer security definition pre-configured.
  • AddAutofacConfiguration() — plugs Autofac as the service provider factory and registers MediatorModule + AuthContextModule.
  • [AuthorizePermissionAttribute] / [PermissionAttribute<TPermission>] / [GenericCrudPermissionAttribute] — declarative permission annotations for controllers and actions.
  • [FeatureFlagAttribute] — action filter that reads a boolean feature flag from IConfiguration and returns 404 when the flag is off.

Configuration

Minimum required — appsettings.json

{
  "LicenseConfigs": {
    "ProjectSeed": "your-unique-16-char-seed-here"
  }
}

AddInfrastructure throws MConfigurationException at startup when ProjectSeed is missing or shorter than 16 characters.

JWT bearer — TokenConfigs

{
  "TokenConfigs": {
    "Issuer": "https://your-issuer",
    "Audience": "your-audience",
    "UseRsa": false,
    "SymmetricSecretKey": "your-hmac-secret-key"
  }
}

Set UseRsa: true and supply PrivateKey (inline PEM) or PrivateKeyPath (file path) to switch to RSA signing.

CORS — MAllowDomains

{
  "MAllowDomains": "https://app.example.com,https://staging.example.com"
}

Causal chain

services.AddMuonroiCausalChain(options =>
{
    options.ServiceName = "my-service";
});

// Attach to an HttpClient:
services.AddHttpClient<IMyServiceClient, MyServiceClient>()
        .AddHttpMessageHandler<MCausalChainDelegatingHandler>();

API Reference

Type Purpose
ServiceCollectionExtensions.AddBaseApi() API versioning + Swagger + health checks
InfrastructureExtensions.AddInfrastructure() Full-stack DI registration
InfrastructureExtensions.AddValidateBearerToken() JWT bearer auth (HMAC or RSA)
InfrastructureExtensions.AddAuthServices<TDbContext, TPermission>() Auth + permission service registration
InfrastructureExtensions.AddPermissionFilter<TPermission>() Global permission MVC filter
InfrastructureExtensions.UseDefaultMiddleware() Standard middleware pipeline
InfrastructureExtensions.ConfigureEndpoints() Swagger UI, controllers, health routes
InfrastructureExtensions.AddAutofacConfiguration() Autofac DI factory + mediator/auth modules
ApplicationExtensions.AddApplication() Lightweight hosting without full infrastructure
ApplicationExtensions.SwaggerConfig() Swagger doc with Bearer security definition
CorsExtensions.AddCors() CORS policy from configuration
CausalChainExtensions.AddMuonroiCausalChain() Outbound causal-chain header propagation
DiagnosticsExtensions.AddMuonroiDiagnostics() Register 6 built-in startup diagnostics
DiagnosticsExtensions.UseMuonroiDiagnostics() Run diagnostics; block on Critical failures
IMEcosystemDiagnostic Interface for custom startup diagnostics
IAuthService<TPermission, TDbContext> Authentication service contract
IPermissionService<TPermission> Permission query contract
ILogSanitizer Log sanitization contract
MCausalChainDelegatingHandler DelegatingHandler that injects correlation headers
GlobalExceptionFilter MVC exception filter with environment-aware responses
LicenseMiddleware Blocks requests when license is invalid
QuotaEnforcementMiddleware Enforces per-tenant request quotas
AuthorizePermissionAttribute Permission-based action authorization
PermissionAttribute<TPermission> Enum-typed permission annotation
FeatureFlagAttribute Configuration-driven feature gate

Samples

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)

License

Apache-2.0. See LICENSE-APACHE for the full text.

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 (2)

Showing the top 2 NuGet packages that depend on Muonroi.AspNetCore:

Package Downloads
Muonroi.BuildingBlock.All

Metapackage for Muonroi Building Block - Includes all sub-packages for a complete infrastructure setup.

Muonroi.AspNetCore.RuleEngine

ASP.NET Core rule engine integration: Auto CRUD with RuleOrchestrator, generic controllers, and rule change management.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 55 6/22/2026
1.0.0-alpha.15 100 5/31/2026
1.0.0-alpha.14 98 5/15/2026
1.0.0-alpha.13 78 5/2/2026
1.0.0-alpha.12 75 4/2/2026
1.0.0-alpha.11 124 4/2/2026
1.0.0-alpha.9 67 3/30/2026
1.0.0-alpha.8 161 3/28/2026
1.0.0-alpha.7 72 3/27/2026
1.0.0-alpha.5 62 3/27/2026
1.0.0-alpha.4 61 3/27/2026
1.0.0-alpha.3 59 3/27/2026
1.0.0-alpha.2 60 3/26/2026
1.0.0-alpha.1 81 3/8/2026