Software license management solution for to easily protect your applications.
The solution is written in the Asp.Net Core MVC - using .NET 6
- Install the latest .NET 6 SDK (using older versions may lead to 502.5 errors when hosted on IIS or application exiting immediately after starting when self-hosted)
- The solution uses these
DbContexts
:DataStoreDbContext
: for Licensing configuration store.DataProtectionDbContext
: for Microsoft Data Protection.
NOTE: Initial migrations are a part of the repository.
- It is possible to use powershell script in folder
build/add-migrations.ps1
. - This script take two arguments:
- --migration (migration name)
- --migrationProviderName (provider type - available choices: All, SqlServer, PostgreSQL)
- For example:
.\add-migrations.ps1 -migration DbInit -migrationProviderName SqlServer
- SqlServer
- PostgreSQL
It is possible to switch the database provider via
appsettings.json
:
"DatabaseProviderConfiguration": {
"ProviderType": "SqlServer"
}
The easiest way to assert the license is in the entry point of your application.
First load the license from a file or resource:
var license = License.Load(...);
Then you can assert the license:
var validation = license.Validate()
.ExpirationDate()
.When(lic => lic.Type == LicenseType.Trial)
.And()
.Signature(publicKey)
.AssertValidLicense();
Licensing class will not throw any Exception and just return an enumeration of validation failures.
Now you can iterate over possible validation failures:
foreach (var failure in validationFailures)
Console.WriteLine(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);
Or simply check if there is any failure:
if (validationFailures.Any())
// ...
Make sure to call validationFailures.ToList()
or validationFailures.ToArray()
before using the result multiple times.
Everyone is welcome to contribute to this project! Feel free to contribute with pull requests, bug reports or enhancement suggestions.
For bugs, questions and discussions please use the GitHub Issues.
- junian/Standard.Licensing for the original work of the library.
This project is licensed under MIT License.