Skip to content

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

11.6 KB
Raw Blame
@page "/settings/server"
@inject ServerSettingsService SettingsService
@using AliasVault.Shared.Server.Models
@using AliasVault.Shared.Server.Services
@inherits MainBase

<LayoutPageTitle>Server settings</LayoutPageTitle>

<PageHeader
    BreadcrumbItems="@BreadcrumbItems"
    Title="Server settings"
    Description="Configure AliasVault server settings.">
    <CustomActions>
        <RefreshButton OnClick="RefreshData" ButtonText="Refresh" />
        <ConfirmButton OnClick="SaveSettings">Save changes</ConfirmButton>
    </CustomActions>
</PageHeader>

<div class="p-4 mb-4 mx-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
    <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">Authentication Settings</h3>
    <div class="grid gap-4 mb-4 sm:grid-cols-2 sm:gap-6 sm:mb-5">
        <div>
            <label for="refreshTokenShort" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Short Refresh Token Lifetime (hours)</label>
            <input type="number" @bind="Settings.RefreshTokenLifetimeShort" id="refreshTokenShort" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Determines how long the user stays logged in after inactivity. Used when "Remember me" is not checked during login.</p>
        </div>
        <div>
            <label for="refreshTokenLong" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Long Refresh Token Lifetime (hours)</label>
            <input type="number" @bind="Settings.RefreshTokenLifetimeLong" id="refreshTokenLong" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Determines how long the user stays logged in after inactivity. Used when "Remember me" is checked during login.</p>
        </div>
        <div>
            <label for="maxRegistrationsPerIp" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Max Registrations per IP per 24 Hours</label>
            <input type="number" @bind="Settings.MaxRegistrationsPerIpPer24Hours" id="maxRegistrationsPerIp" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Maximum number of new account registrations allowed from a single IP address (/24 range) within a 24 hour period. Set to 0 to disable rate limiting. Recommended: 5-10 for most deployments.</p>
        </div>
        <div>
            <label for="maxMobileLoginRequestsPerIp" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Max Mobile Login Requests per IP per Minute</label>
            <input type="number" @bind="Settings.MaxMobileLoginRequestsPerIpPerMinute" id="maxMobileLoginRequestsPerIp" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Maximum number of QR code mobile login requests that can be started from a single IP address (/24 range) within one minute. Set to 0 to disable rate limiting. Recommended: 10 for most deployments.</p>
        </div>
        <div>
            <label for="maxLoginAttemptsPerIp" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Max Login Attempts per IP per Minute</label>
            <input type="number" @bind="Settings.MaxLoginAttemptsPerIpPerMinute" id="maxLoginAttemptsPerIp" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Maximum number of logins (across all accounts) that can be started from a single IP address within one minute. Counted on the full IP (IPv6 per /64), never stored. Users behind a shared IP (office, VPN, carrier NAT) count together; raise it when many users share one IP. Set to 0 to disable. Recommended: 10.</p>
        </div>
    </div>
</div>

<div class="p-4 mb-4 mx-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
    <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">General Data Retention</h3>
    <div class="grid gap-4 mb-4 sm:grid-cols-2 sm:gap-6 sm:mb-5">
        <div>
            <label for="generalLogRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">General Log Retention (days)</label>
            <input type="number" @bind="Settings.GeneralLogRetentionDays" id="generalLogRetention" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of days to keep general logs before deletion. Set to 0 to disable automatic cleanup.</p>
        </div>
        <div>
            <label for="authLogRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Auth Log Retention (days)</label>
            <input type="number" @bind="Settings.AuthLogRetentionDays" id="authLogRetention" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of days to keep auth logs before deletion. Set to 0 to disable automatic cleanup.</p>
        </div>
        <div>
            <label for="mobileLoginLogRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Mobile Login Log Retention (days)</label>
            <input type="number" @bind="Settings.MobileLoginLogRetentionDays" id="mobileLoginLogRetention" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">
                Number of days to keep mobile login request logs before deletion. Set to 0 to disable automatic cleanup.            </p>
        </div>
        <div>
            <label for="unlockMethodHistoryRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password Revert Window (days)</label>
            <input type="number" @bind="Settings.UnlockMethodHistoryRetentionDays" id="unlockMethodHistoryRetention" min="0" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">
                Number of days a user's previous master password credentials are kept after a password change, so that
                an admin can revert the change for a user who can no longer log in. Set to 0 disable retention.
            </p>
        </div>
    </div>
</div>

<div class="p-4 mb-4 mx-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
    <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">Email Settings</h3>
    <div class="grid gap-4 mb-4 sm:grid-cols-2 sm:gap-6 sm:mb-5">
        <div>
            <label for="emailRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">General Email Retention (days)</label>
            <input type="number" @bind="Settings.EmailRetentionDays" id="emailRetention" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of days to keep emails before deletion. This affects all emails for all users. Set to 0 to disable automatic cleanup.</p>
        </div>
        <div>
            <label for="disabledEmailRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Disabled Email Retention (days)</label>
            <input type="number" @bind="Settings.DisabledEmailRetentionDays" id="disabledEmailRetention" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of days to keep emails for disabled aliases before deletion. A disabled alias is an alias that was originally claimed by a user, but has since been changed or deleted. Set to 0 to disable automatic cleanup.</p>
        </div>
        <div>
            <label for="maxEmails" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Max Emails per User</label>
            <input type="number" @bind="Settings.MaxEmailsPerUser" id="maxEmails" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
            <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of emails a user can have in total. Emails exceeding this limit will be deleted, oldest first. Set to 0 for unlimited emails</p>
        </div>
    </div>
</div>

@code {
    private ServerSettingsModel Settings { get; set; } = new();

    /// <inheritdoc/>
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Server settings" });

        Settings = await SettingsService.GetAllSettingsAsync();
    }

    private async Task SaveSettings()
    {
        await SettingsService.SaveSettingsAsync(Settings);
        GlobalNotificationService.AddSuccessMessage("Settings saved successfully", true);
    }

    /// <summary>
    /// Refreshes the data displayed on the page.
    /// </summary>
    private async Task RefreshData()
    {
        Settings = await SettingsService.GetAllSettingsAsync();
    }
}