AutoLicensing.AspNetCore 2.3.0

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

AutoLicensing

NuGet NuGet NuGet

Open-source license manager for .NET. Generate RSA-signed licenses, embed features and limits per product, and enforce them at runtime — including out-of-the-box ASP.NET Core middleware.

Packages

Package Purpose
AutoLicensing Core: license model, RSA signing/verification, key generation
AutoLicensing.Generator Fluent license builders for issuing licenses
AutoLicensing.AspNetCore DI registration + middleware / MVC filter that blocks disabled features

Install

dotnet add package AutoLicensing
dotnet add package AutoLicensing.Generator
dotnet add package AutoLicensing.AspNetCore

AutoLicensing.Generator and AutoLicensing.AspNetCore reference the core package — install only what you use.

Frameworks

Package .NET 8 .NET 9 .NET 10
AutoLicensing ✅ ✅ ✅
AutoLicensing.Generator ✅ — ✅
AutoLicensing.AspNetCore ✅ ✅ ✅

How it works

A license is a JSON payload — license name, customer, and one or more products. Each product carries:

  • Features — named on/off switches
  • Attributes — key/value limits (int, decimal, or string)
  • Issue / expiry dates

The payload is signed with your RSA private key; the signature is XOR-obfuscated with the Confuser bytes. The result is exported as a single base64 string — the license key your customer installs.

Verification uses your public key only. You never ship the private key.

Generate a license

var key = LicenseKeyGenerator.GenerateRsaKeyPair(); // keep PrivateKey to yourself

var signedLicense = new LicenseFactory()
    .WithRsaPrivateKey(key.PrivateKey)
    .WithName("Enterprise License")
    .WithCustomerName("Some Guy")
    .WithProduct(new LicenseProductFactory()
        .WithName("Application 1")
        .WithExpiryDate(DateTime.Now.AddDays(180))
        .WithAttribute("Limitation 1", 100)
        .WithFeature("Feature 1")
        .WithFeature("Feature 2")
        .Create())
    .SignAndCreate();

var licenseKey = signedLicense.Export(); // give this to the customer

Verify a license

var signedLicense = Licenser.Verifier
    .WithRsaPublicKey(publicKey)
    .LoadAndVerify(licenseKey); // throws AutoLicensingException if the signature is invalid

Read license data

var product = signedLicense.License.GetProduct("Application 1");

if (product.IsFeatureEnabled("Feature 1")) { /* feature gate */ }

var limit = product.GetAttribute("Limitation 1").AsInteger();

LicenseAttribute value converters: AsString(), AsInteger(), AsDecimal().

ASP.NET Core enforcement

Register the license and middleware in Program.cs:

builder.Services.AddAutoLicensing("Application 1", publicKey, licenseKey);

var app = builder.Build();

app.UseRouting();
app.UseAutoLicensing(); // register after UseRouting to keep streaming responses un-buffered
app.MapControllers();

AddAutoLicensing validates the signature up front and throws AutoLicensingException if the product name is unknown or the license is expired.

Gate any endpoint behind a feature with the HasFeature attribute — disabled features return 404 Not Found:

[HasFeature("Feature 1")]
[HttpGet("premium")]
public IActionResult Premium() => Ok("Premium endpoint");

SSE / streaming: the middleware only buffers the response when the endpoint is not yet resolved (i.e. registered before UseRouting). Register it after UseRouting so feature checks run before the endpoint and streaming responses (SSE, file downloads) pass through untouched.

MVC filter alternative

If you use MapControllers, register feature gating as an MVC authorization filter instead of middleware. It runs after the action is resolved, so it never buffers the response — safe for streaming/SSE endpoints no matter where it's placed:

builder.Services.AddAutoLicensing("Application 1", publicKey, licenseKey);
builder.Services.AddControllers().AddLicenseFeatureGating();

Same [HasFeature] attribute and same 404 behavior. Don't register both — one gate is enough.

Customize the obfuscation bytes

Signature obfuscation must match between signer and verifier. Change the default on both sides:

Confuser.ConfusingBytes = "Some random bytes"u8.ToArray();

Publishing to NuGet

Create and push all three packages with one script:

.\scripts\publish.ps1 -ApiKey <your-api-key>
# or set the key once: $env:NUGET_API_KEY = "<your-api-key>"

Get an API key at https://www.nuget.org/account/apikeys. Push is permanent — the same version of a package ID can't be re-uploaded.

License

MIT

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 is compatible.  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 is compatible.  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
2.3.0 132 8/16/2026
2.2.0 122 8/16/2026
2.1.1 322 3/4/2025
2.1.0 223 3/3/2025
2.0.0 226 3/3/2025
1.0.6 291 1/31/2024
1.0.5 200 1/31/2024
1.0.3 196 1/31/2024
1.0.2 196 1/31/2024
1.0.1 199 1/30/2024