-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
This guide covers all configuration options available in the REDZAuth API, including database settings, security configurations, and webhook setup.
-
appsettings.json- Main configuration file -
appsettings.Development.json- Development-specific settings -
appsettings.Example.json- Example configuration template
{
"ConnectionStrings": {
"MongoDB": "mongodb://localhost:27017"
}
}{
"ConnectionStrings": {
"MongoDB": "mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority"
}
}{
"ConnectionStrings": {
"MongoDB": "mongodb://username:password@localhost:27017/database?authSource=admin"
}
}The API automatically creates the following collections:
- Users - User accounts and authentication data
- Licenses - License keys and their usage status
- Blacklist - Banned users, IPs, and HWIDs
{
"SecuritySettings": {
"AesEncryptionKey": "YOUR_32_CHARACTER_ENCRYPTION_KEY_HERE"
}
}Important Requirements:
- Must be exactly 32 characters long
- Should contain a mix of letters, numbers, and special characters
- Keep this key secure and never commit it to version control
Use one of these methods to generate a 32-character key:
PowerShell:
-join ((65..90) + (97..122) + (48..57) | Get-Random -Count 32 | % {[char]$_})Online Generator:
- Use a secure password generator
- Ensure it generates exactly 32 characters
Manual Generation: Create a key with a mix of:
- Uppercase letters (A-Z)
- Lowercase letters (a-z)
- Numbers (0-9)
- Special characters (!@#$%^&*)
- Go to your Discord server
- Right-click on a channel
- Select "Edit Channel"
- Go to "Integrations" tab
- Click "Create Webhook"
- Copy the webhook URL
{
"WebhookSettings": {
"DiscordWebhookUrl": "https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
}
}The API sends notifications for:
- User Registration - New account creation
- Login Attempts - Successful and failed logins
- HWID Changes - Device ID modifications
- Ban/Unban Actions - User management events
- License Expiration - Expired license attempts
To disable webhook notifications, either:
- Remove the
WebhookSettingssection - Set the URL to an empty string
- Use the placeholder value:
"YOUR_DISCORD_WEBHOOK_URL_HERE"
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}Available log levels:
-
Trace- Most detailed logging -
Debug- Debug information -
Information- General information -
Warning- Warning messages -
Error- Error messages -
Critical- Critical errors
The API uses console logging by default. For production, consider:
- Implementing structured logging
- Using a logging framework like Serilog
- Sending logs to external services
{
"AllowedHosts": "*"
}For production, specify allowed hosts:
{
"AllowedHosts": "yourdomain.com,www.yourdomain.com"
}The API runs on HTTPS by default. Configure certificates in:
-
Properties/launchSettings.jsonfor development - Server configuration for production
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"MongoDB": "mongodb://localhost:27017"
},
"WebhookSettings": {
"DiscordWebhookUrl": "YOUR_DISCORD_WEBHOOK_URL_HERE"
},
"SecuritySettings": {
"AesEncryptionKey": "YOUR_32_CHARACTER_ENCRYPTION_KEY_HERE"
}
}For production, use environment variables:
Windows:
set ConnectionStrings__MongoDB="your-connection-string"
set SecuritySettings__AesEncryptionKey="your-encryption-key"
set WebhookSettings__DiscordWebhookUrl="your-webhook-url"Linux/macOS:
export ConnectionStrings__MongoDB="your-connection-string"
export SecuritySettings__AesEncryptionKey="your-encryption-key"
export WebhookSettings__DiscordWebhookUrl="your-webhook-url"Docker:
ENV ConnectionStrings__MongoDB="your-connection-string"
ENV SecuritySettings__AesEncryptionKey="your-encryption-key"
ENV WebhookSettings__DiscordWebhookUrl="your-webhook-url"The API supports these license plans:
-
mensal- 30 days -
trimestral- 91 days -
anual- 366 days -
lifetime- 9999 days (effectively unlimited)
To modify plan durations, edit the GetDaysForPlan method in Services/LicenseService.cs:
private int GetDaysForPlan(string plan)
{
return plan.ToLower() switch
{
"mensal" => 30,
"trimestral" => 91,
"anual" => 366,
"lifetime" => 9999,
"custom" => 60, // Add custom plans here
_ => 30
};
}The API uses SHA256 for password hashing. To change the algorithm, modify the HashPassword method in Services/AuthService.cs.
HWID validation is enabled by default. To disable or modify:
- Edit the login logic in
Services/AuthService.cs - Modify the HWID comparison logic
IP addresses are automatically captured from requests. To modify IP detection:
- Edit the IP extraction logic in controllers
- Consider using proxy headers for load balancers
The API validates these required configurations:
- MongoDB connection string
- AES encryption key (32 characters)
- Valid JSON format
If configuration is invalid, the API will:
- Log error messages to console
- Throw exceptions during startup
- Display clear error messages