Muonroi.AspNetCore
1.0.0-alpha.16
dotnet add package Muonroi.AspNetCore --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.AspNetCore -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.AspNetCore" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.AspNetCore" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.AspNetCore" />
paket add Muonroi.AspNetCore --version 1.0.0-alpha.16
#r "nuget: Muonroi.AspNetCore, 1.0.0-alpha.16"
#:package Muonroi.AspNetCore@1.0.0-alpha.16
#addin nuget:?package=Muonroi.AspNetCore&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.AspNetCore&version=1.0.0-alpha.16&prerelease
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.
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 withReportApiVersions),SwaggerGen, and health checks in one call.AddInfrastructure()— full-stack registration: controllers withGlobalExceptionFilter+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; lazyIssuerSigningKeyResolver.AddAuthServices<TDbContext, TPermission>()— registersIAuthService<TPermission, TDbContext>andIPermissionService<TPermission>.AddPermissionFilter<TPermission>()— global MVCPermissionFilter<TPermission>for attribute-driven access control.UseDefaultMiddleware()— pipeline order:TenantContextMiddleware(when tenancy enabled) →QuotaEnforcementMiddleware→LicenseMiddleware→MExceptionMiddleware→MCookieAuthMiddleware.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 (MAllowDomainsconfig key), with the standard Muonroi header and method set.AddMuonroiCausalChain()+MCausalChainDelegatingHandler— propagates correlation/causation headers across outboundHttpClientcalls.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 registersMediatorModule+AuthContextModule.[AuthorizePermissionAttribute]/[PermissionAttribute<TPermission>]/[GenericCrudPermissionAttribute]— declarative permission annotations for controllers and actions.[FeatureFlagAttribute]— action filter that reads a boolean feature flag fromIConfigurationand 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
- Quickstart.AspNetCore — minimal
AddBaseApi()setup: API versioning, Swagger, health checks. - Quickstart.AspNetCore.RuleEngine —
AddBaseApi()combined with the Rule Engine, demonstrating a rule-order controller wired into the Muonroi hosting layer.
Compatibility
- Target framework:
net8.0 - License: Apache-2.0 (OSS)
Related Packages
Muonroi.Core— core services (IMDateTimeService,IMLog,MException) used throughout this packageMuonroi.Core.Abstractions— shared contracts and guardsMuonroi.Tenancy.Core— tenant context and middleware registered byAddInfrastructureMuonroi.Data.EntityFrameworkCore—MDbContextrequired byAddAuthServicesMuonroi.Mediator— mediator registered byAddApplicationandAddInfrastructureMuonroi.Governance— policy-decision services wired byAddInfrastructureMuonroi.AspNetCore.OpenApi— OpenAPI operation filters used bySwaggerConfig
License
Apache-2.0. See LICENSE-APACHE for the full text.
| 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
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- Autofac.Extensions.DependencyInjection (>= 10.0.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.15)
- Microsoft.Bcl.Memory (>= 9.0.14)
- Muonroi.AspNetCore.OpenApi (>= 1.0.0-alpha.16)
- Muonroi.BackgroundJobs.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Caching.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Caching.Memory (>= 1.0.0-alpha.16)
- Muonroi.Core (>= 1.0.0-alpha.16)
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Data.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Data.EntityFrameworkCore (>= 1.0.0-alpha.16)
- Muonroi.Governance (>= 1.0.0-alpha.16)
- Muonroi.Governance.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Http (>= 1.0.0-alpha.16)
- Muonroi.Mapper (>= 1.0.0-alpha.16)
- Muonroi.Mediator (>= 1.0.0-alpha.16)
- Muonroi.Tenancy.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Tenancy.Core (>= 1.0.0-alpha.16)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- Scriban (>= 7.2.1)
- Swashbuckle.AspNetCore (>= 8.1.4)
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 |