AutoLicensing 2.3.0
dotnet add package AutoLicensing --version 2.3.0
NuGet\Install-Package AutoLicensing -Version 2.3.0
<PackageReference Include="AutoLicensing" Version="2.3.0" />
<PackageVersion Include="AutoLicensing" Version="2.3.0" />
<PackageReference Include="AutoLicensing" />
paket add AutoLicensing --version 2.3.0
#r "nuget: AutoLicensing, 2.3.0"
#:package AutoLicensing@2.3.0
#addin nuget:?package=AutoLicensing&version=2.3.0
#tool nuget:?package=AutoLicensing&version=2.3.0
AutoLicensing
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 afterUseRoutingso 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 | 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 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. |
-
net10.0
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on AutoLicensing:
| Package | Downloads |
|---|---|
|
AutoLicensing.AspNetCore
AutoLicensing is an open-source license manager. |
|
|
AutoLicensing.Extensions.DependencyInjection
AutoLicensing is an open-source license manager. |
|
|
AutoLicensing.Generator
AutoLicensing is an open-source license manager. |
GitHub repositories
This package is not used by any popular GitHub repositories.