SkillAgentSearch skills...

Aegis

Aegis is a robust and flexible .NET licensing library that simplifies the implementation of various licensing models for your applications. It offers strong security features, both online and offline validation, and easy integration with your existing projects. Securely manage your software licenses with Aegis.

Install / Use

/learn @LSXPrime/Aegis
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Aegis - Robust and Flexible .NET Licensing Solution

Aegis is a comprehensive and versatile licensing library for .NET applications, empowering developers to implement various licensing models with ease. It offers strong security features, offline validation, and seamless integration with your existing applications.

Features

  • Diverse Licensing Models:
    • Standard License: A basic license model for single-user applications.
    • Trial License: A time-limited license for evaluation purposes, with a defined trial period.
    • Node-Locked License: Licenses tied to specific hardware, preventing unauthorized usage on different machines.
    • Subscription License: Licenses valid for a specific duration, suitable for subscription-based services.
    • Floating License: Licenses managed on a server, allowing concurrent usage by a limited number of users within an organization.
    • Concurrent License: Licenses that allow a maximum number of simultaneous users, ideal for applications with shared access.
  • Strong Security: Utilizes RSA encryption, digital signatures, and checksum verification to protect your licenses from tampering and unauthorized modifications.
  • License Validation: Offers both online and offline license validation modes, ensuring flexibility even in scenarios without internet connectivity.
  • Custom Validation Rules: Define and apply custom validation rules using IValidationRule and IValidationRuleGroup for tailored license requirements.
  • Easy Integration: Provides a simple and intuitive API for generating, saving, loading, validating, and managing licenses within your .NET applications.
  • Ease of Use: Provides a fluent API for building and managing licenses, simplifying integration into existing projects.
  • Built-in Exceptions: Includes a set of exceptions for common licensing scenarios, simplifying error handling.
  • Advanced Feature Management:
    • Centralized management of feature-related operations using the FeatureManager.
    • Supports various data types for features (Boolean, Integer, Float, String, DateTime, ByteArray).
    • Methods to check feature enablement & retrieve feature values of different types

Aegis.Server - Backend for Floating and Concurrent Licenses

Aegis.Server is a lightweight backend service designed to handle floating and concurrent license management. It provides a foundation for building your own licensing server, offering functionalities like:

  • License Generation and Validation: Generate, validate, activate, and revoke licenses securely.
  • User Authentication: Securely register and authenticate users for accessing license-related operations.
  • Heartbeat Monitoring: Track active concurrent license usage and automatically disconnect idle users.

You can integrate Aegis.Server into your preferred web framework or create a custom implementation based on your specific needs. Aegis.Server provides the core logic for license management, while allowing you to choose how you want to expose the functionality.

Aegis.Server.AspNetCore

A sample implementation of Aegis.Server using ASP.NET Core is available in the Aegis.Server.AspNetCore project. This implementation showcases how to integrate Aegis.Server into an ASP.NET Core application, providing ready-to-use controllers and middlewares for:

  • RESTful API Endpoints: Access license management functionalities through a well-defined API.
  • Authentication and Authorization: Secure access to API endpoints using JWT and API keys.
  • Rate Limiting: Control the rate of requests to the server.
  • Swagger Documentation: Explore the API endpoints using the interactive Swagger UI.

The Aegis.Server.AspNetCore project can be used as a starting point for building your own licensing server, or you can adapt the provided code to your specific needs.

Getting Started

Aegis NuGet Package

  1. Install the Aegis NuGet package:

    Install-Package Aegis
    
  2. Generate Licensing Secrets:

    // Replace "your-secret-key" and "C:\Path\To\signature.bin" with your desired secret key and save path.
    var signature = LicenseUtils.GenerateLicensingSecrets("your-secret-key", @"C:\Path\To\signature.bin", "your-server-api-key"); 
    

    This will generate a new RSA key pair and an encryption key. The public key, private key, and encryption key are encrypted with AES using your provided secret key and saved to the specified file path (signature.bin in this example).

  3. Load Licensing Secrets:

    // Load the secret keys from the signature file
    var signature = LicenseUtils.LoadLicensingSecrets("your-secret-key", @"C:\Path\To\signature.bin");
    

    Use the same secret key to decrypt and load the licensing secrets from the file you created in step 2.

    Alternatively, you can:

    • Load directly from the configuration section:
    var signature = LicenseUtils.LoadLicensingSecrets(config.GetSection("LicensingSecrets"))
    
    • Add the keys to your User Secrets and they will be retrieved automatically.
  4. Generate and Save a License (Examples for each license type):

    Standard License:

    using Aegis;
    using Aegis.Models;
    
    var license = LicenseGenerator.GenerateStandardLicense("John Doe")
        .WithLicenseKey("SD2D-35G9-1502-X3DG-16VI-ELN2")
        .WithIssuer("Aegis Software")
        .WithFeature("Feature1", Feature.FromBool(true))
        .WithFeature("Feature2", Feature.FromString("Enabled"))
        .WithExpiryDate(DateTime.UtcNow.AddDays(30))
        .SaveLicense(@"C:\Path\To\license.bin"); 
    

    Trial License:

    var license = LicenseGenerator.GenerateTrialLicense(TimeSpan.FromDays(14))
        .WithIssuer("Aegis Software")
        .WithFeature("AllFeatures", Feature.FromBool(true))
        .SaveLicense(@"C:\Path\To\trial_license.bin");
    

    Node-Locked License:

    var license = LicenseGenerator.GenerateNodeLockedLicense(HardwareUtils.GetHardwareId()) 
        .WithIssuer("Aegis Software")
        .WithExpiryDate(DateTime.UtcNow.AddYears(1))
        .SaveLicense(@"C:\Path\To\nodelocked_license.bin");
    

    Subscription License:

    var license = LicenseGenerator.GenerateSubscriptionLicense("Jane Smith", TimeSpan.FromDays(365))
        .WithIssuer("Aegis Software")
        .WithFeature("PremiumFeatures", Feature.FromBool(true))
        .SaveLicense(@"C:\Path\To\subscription_license.bin");
    

    Floating License:

    var license = LicenseGenerator.GenerateFloatingLicense("Acme Corp", 20) // 20 concurrent users allowed
        .WithIssuer("Aegis Software")
        .SaveLicense(@"C:\Path\To\floating_license.bin");
    

    Concurrent License:

    var license = LicenseGenerator.GenerateConcurrentLicense("Tech Solutions", 5) // 5 concurrent users allowed
        .WithIssuer("Aegis Software")
        .WithExpiryDate(DateTime.UtcNow.AddYears(1))
        .SaveLicense(@"C:\Path\To\concurrent_license.bin");
    
  5. Load and Validate a License:

    try
    {
         var loadedLicenseResult = await LicenseManager.LoadLicenseAsync(@"C:\Path\To\license.bin");
         if (loadedLicenseResult.Status == Aegis.Enums.LicenseStatus.Valid)
         {
             var loadedLicense = loadedLicenseResult.License;
             // License loaded successfully, you can access its properties:
             Console.WriteLine("License Type: " + loadedLicense!.Type);
             Console.WriteLine("Expiration Date: " + loadedLicense.ExpirationDate);
         }
         else
         {
             // Handle invalid license status
             Console.WriteLine($"License status is: {loadedLicenseResult.Status}");
         }
    }
    catch (LicenseValidationException ex)
    {
        // Handle license validation errors (e.g., expired, invalid signature, etc.)
        Console.WriteLine("License Validation Error: " + ex.Message);
    }
    catch (Exception ex)
    {
        // Handle other errors (e.g., file not found, invalid format, etc.)
        Console.WriteLine("Error Loading License: " + ex.Message);
    } 
    

Aegis.Server NuGet Package

  1. Install the Aegis.Server NuGet package:
    Install-Package Aegis.Server
    
  2. Integrate Aegis.Server into an ASP.NET Core application:
    // In your Startup.cs file:
    services.AddAegisServer();
    
  3. Inherit your DbContext from AegisDbContext class:
    using Aegis.Server.Data;
    
    public class ApplicationDbContext(DbContextOptions<AegisDbContext> options) : AegisDbContext(options)
    {
        // ...
    }
    
  4. Inject LicenseService in your Controller:
    using Aegis.Server.Services;
    
    public class LicensesController(LicenseService licenseService)
    {
        // ...
    }
    

Aegis.Server.AspNetCore Sample Implementation

  1. Clone the Aegis repository and acquire Aegis.Server.AspNetCore from Samples directory:

    git clone https://github.com/LSXPrime/Aegis.git
    
  2. Configure the database connection:

    • Open the appsettings.json file in the Aegis.Server.AspNetCore project.
    • Modify the DefaultConnection connection string to point to your SQLite database file. For example:
      "ConnectionStrings": {
        "DefaultConnection": "Data Source=C:\\Path\\To\\Your\\Database\\Aegis.db"
      }
      
  3. Set the JWT settings:

    • In appsettings.json, configure the JwtSettings section with your secret key, salt, and token expiration settings:
      "JwtSettings": {
        "Secret": "your_jwt_secret_key",
        "Salt": "your_password_salt",
        "AccessTokenExpirationInDays": 1,
        "RefreshTokenExpirationInDays": 7
      }
      
    • Security Considerations: Use strong and unique values for your JWT secret key and password salt. Keep them confidential
View on GitHub
GitHub Stars269
CategoryDevelopment
Updated2d ago
Forks26

Languages

C#

Security Score

100/100

Audited on Mar 26, 2026

No findings