Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add max aliases for new accounts settings (#2131)

Leendert de Borst7979f9ebf578
diff --git a/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs b/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs
index b7d7afd7f..07132534c 100644
--- a/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs
+++ b/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs
@@ -84,4 +84,17 @@ public class ServerSettingsModel
/// Set to 0 to disable IP-based registration rate limiting.
/// </summary>
public int MaxRegistrationsPerIpPer24Hours { get; set; } = 5;
+
+ /// <summary>
+ /// Gets or sets the age (in days) below which an account is considered "new" for alias-creation limiting purposes.
+ /// Defaults to 0 (disabled). When 0, or when MaxAliasesForNewAccounts is 0, no new-account alias limit is applied.
+ /// </summary>
+ public int NewAccountAliasLimitDays { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum number of active aliases a "new" account (younger than NewAccountAliasLimitDays) may
+ /// have. Defaults to 0 (unlimited). When the limit is reached, additional alias creation is silently skipped
+ /// during vault sync.
+ /// </summary>
+ public int MaxAliasesForNewAccounts { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs b/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs
index 4fa8217ae..c119fed33 100644
--- a/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs
+++ b/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs
@@ -180,6 +180,16 @@ public class ServerSettingsService(IAliasServerDbContextFactory dbContextFactory
model.MobileLoginLogRetentionDays = mobileLoginDays;
}
+ if (int.TryParse(settings.GetValueOrDefault("NewAccountAliasLimitDays"), out var newAccountAliasLimitDays))
+ {
+ model.NewAccountAliasLimitDays = newAccountAliasLimitDays;
+ }
+
+ if (int.TryParse(settings.GetValueOrDefault("MaxAliasesForNewAccounts"), out var maxAliasesForNewAccounts))
+ {
+ model.MaxAliasesForNewAccounts = maxAliasesForNewAccounts;
+ }
+
return model;
}
@@ -203,5 +213,7 @@ public class ServerSettingsService(IAliasServerDbContextFactory dbContextFactory
await SetSettingAsync("RefreshTokenLifetimeLong", model.RefreshTokenLifetimeLong.ToString());
await SetSettingAsync("MaxRegistrationsPerIpPer24Hours", model.MaxRegistrationsPerIpPer24Hours.ToString());
await SetSettingAsync("MobileLoginLogRetentionDays", model.MobileLoginLogRetentionDays.ToString());
+ await SetSettingAsync("NewAccountAliasLimitDays", model.NewAccountAliasLimitDays.ToString());
+ await SetSettingAsync("MaxAliasesForNewAccounts", model.MaxAliasesForNewAccounts.ToString());
}
}