4.8 KiB
License Keys Setup Guide
This document explains how to configure license keys for MediatR 13.x and AutoMapper 15.x.
Overview
ColaFlow API uses commercial versions of:
- MediatR 13.1.0 - Requires a license key
- AutoMapper 15.1.0 - Requires a license key (if used)
Configuration Methods
Option 1: User Secrets (Recommended for Development)
This is the most secure method for local development:
cd colaflow-api/src/ColaFlow.API
# Set MediatR license key
dotnet user-secrets set "MediatR:LicenseKey" "your-actual-mediatr-license-key-here"
# Set AutoMapper license key (if you use AutoMapper)
dotnet user-secrets set "AutoMapper:LicenseKey" "your-actual-automapper-license-key-here"
Advantages:
- Secrets are stored outside the project directory
- Never accidentally committed to Git
- Scoped per-user, per-project
Option 2: appsettings.Development.json (Quick Setup)
For quick local setup, you can directly edit the configuration file:
-
Open
colaflow-api/src/ColaFlow.API/appsettings.Development.json -
Replace the placeholder values:
{
"MediatR": {
"LicenseKey": "your-actual-mediatr-license-key-here"
},
"AutoMapper": {
"LicenseKey": "your-actual-automapper-license-key-here"
}
}
Warning: Be careful not to commit actual license keys to Git!
Option 3: Environment Variables (Production)
For production environments, use environment variables:
# Windows (PowerShell)
$env:MediatR__LicenseKey = "your-actual-mediatr-license-key-here"
$env:AutoMapper__LicenseKey = "your-actual-automapper-license-key-here"
# Linux/Mac (Bash)
export MediatR__LicenseKey="your-actual-mediatr-license-key-here"
export AutoMapper__LicenseKey="your-actual-automapper-license-key-here"
Note: Use double underscores __ to represent nested configuration keys.
Option 4: Azure Key Vault (Production - Most Secure)
For production on Azure, store license keys in Azure Key Vault:
// In Program.cs
builder.Configuration.AddAzureKeyVault(
new Uri($"https://{keyVaultName}.vault.azure.net/"),
new DefaultAzureCredential()
);
Then create secrets in Azure Key Vault:
MediatR--LicenseKeyAutoMapper--LicenseKey
Verification
After setting up the license keys, verify the configuration:
1. Build the project
cd colaflow-api
dotnet clean
dotnet restore
dotnet build
Expected: No license warnings in the build output.
2. Run the API
cd src/ColaFlow.API
dotnet run
Expected: API starts without license warnings in the console.
3. Check the logs
Look for startup logs - there should be no warnings about missing or invalid license keys.
Troubleshooting
Warning: "No license key configured for MediatR"
Solution: Ensure the license key is correctly configured using one of the methods above.
Warning: "Invalid license key for MediatR"
Possible causes:
- The license key is incorrect or expired
- The license key contains extra whitespace (trim it)
- The license key is for a different version
Solution: Verify the license key with the vendor.
Configuration not loading
Check:
- User secrets are set for the correct project
- appsettings.Development.json is valid JSON
- Environment variables use double underscores
__for nested keys - The application is running in the expected environment (Development/Production)
Getting License Keys
MediatR License
- Purchase from: https://www.mediator.dev/licensing
- Contact: license@mediator.dev
AutoMapper License
- Purchase from: https://www.automapper.org/
- Contact: support@automapper.org
Security Best Practices
-
Never commit license keys to Git
- Use
.gitignoreto exclude sensitive files - Use User Secrets for local development
- Use environment variables or Key Vault for production
- Use
-
Rotate keys regularly
- Update license keys when they expire
- Remove old keys from all environments
-
Limit access
- Only share keys with authorized team members
- Use separate keys for development and production if possible
-
Monitor usage
- Track which applications use which license keys
- Audit key usage regularly
Configuration Priority
.NET configuration uses the following priority (highest to lowest):
- Command-line arguments
- Environment variables
- User secrets (Development only)
- appsettings.{Environment}.json
- appsettings.json
Later sources override earlier ones.
Support
If you encounter issues with license key configuration:
- Check this guide for troubleshooting steps
- Verify your license key validity with the vendor
- Contact the development team for assistance
Last Updated: 2025-11-03 ColaFlow Version: 1.0.0 MediatR Version: 13.1.0 AutoMapper Version: 15.1.0