From 20eb3e5ff485385e49820898e49a724613dc7603 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 20 Dec 2024 15:56:30 +0100 Subject: [PATCH 1/5] Add public registration setting to install.sh (#343) --- docs/installation/install.md | 16 ++++- install.sh | 136 +++++++++++++++++++++++++++++------ 2 files changed, 130 insertions(+), 22 deletions(-) diff --git a/docs/installation/install.md b/docs/installation/install.md index 30388a35..5a874638 100644 --- a/docs/installation/install.md +++ b/docs/installation/install.md @@ -128,7 +128,21 @@ If you encounter any issues, feel free to open an issue on the [GitHub repositor --- -## 4. Troubleshooting +## 4. Configure Account Registration + +By default, AliasVault is configured to allow public registration of new accounts. This means that anyone can create a new account on your server. + +If you want to disable public registration, you can do so by running the install script with the `configure-registration` option and then choosing option 2. + +```bash +./install.sh configure-registration +``` + +> Note: disabling public registration means the ability to create new accounts in the AliasVault client is disabled for everyone, including administrators. Accounts cannot be created outside of the client because of the end-to-end encryption employed by AliasVault. So make sure you have created your own account(s) before disabling public registration. + +--- + +## 5. Troubleshooting ### Resetting the admin password If you have lost your admin password, you can reset it by running the install script with the `reset-password` option. This will generate a new random password and update the .env file with it. After that it will restart the AliasVault containers to apply the changes. diff --git a/install.sh b/install.sh index ad088d3e..6b404b09 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/bin/bash -# @version 0.9.4 +# @version 0.10.0 # Repository information used for downloading files and images from GitHub REPO_OWNER="lanedirt" @@ -38,17 +38,18 @@ show_usage() { printf "Usage: $0 [COMMAND] [OPTIONS]\n" printf "\n" printf "Commands:\n" - printf " install Install AliasVault by pulling pre-built images from GitHub Container Registry (recommended)\n" - printf " uninstall Uninstall AliasVault\n" - printf " update Update AliasVault to the latest version\n" - printf " update-installer Check and update install.sh script if newer version available\n" - printf " configure-ssl Configure SSL certificates (Let's Encrypt or self-signed)\n" - printf " configure-email Configure email domains for receiving emails\n" - printf " start Start AliasVault containers\n" - printf " stop Stop AliasVault containers\n" - printf " restart Restart AliasVault containers\n" - printf " reset-password Reset admin password\n" - printf " build Build AliasVault from source (takes longer and requires sufficient specs)\n" + printf " install Install AliasVault by pulling pre-built images from GitHub Container Registry (recommended)\n" + printf " uninstall Uninstall AliasVault\n" + printf " update Update AliasVault to the latest version\n" + printf " update-installer Check and update install.sh script if newer version available\n" + printf " configure-ssl Configure SSL certificates (Let's Encrypt or self-signed)\n" + printf " configure-email Configure email domains for receiving emails\n" + printf " configure-registration Configure new account registration (enable or disable)\n" + printf " start Start AliasVault containers\n" + printf " stop Stop AliasVault containers\n" + printf " restart Restart AliasVault containers\n" + printf " reset-password Reset admin password\n" + printf " build Build AliasVault from source (takes longer and requires sufficient specs)\n" printf "\n" printf "Options:\n" @@ -101,6 +102,10 @@ parse_args() { COMMAND="configure-email" shift ;; + configure-registration|registration) + COMMAND="configure-registration" + shift + ;; start|s) COMMAND="start" shift @@ -186,6 +191,9 @@ main() { "configure-email") handle_email_configuration ;; + "configure-registration") + handle_registration_configuration + ;; "start") handle_start ;; @@ -363,6 +371,15 @@ set_support_email() { fi } +set_public_registration() { + printf "${CYAN}> Checking PUBLIC_REGISTRATION...${NC}\n" + if ! grep -q "^PUBLIC_REGISTRATION=" "$ENV_FILE" || [ -z "$(grep "^PUBLIC_REGISTRATION=" "$ENV_FILE" | cut -d '=' -f2)" ]; then + update_env_var "PUBLIC_REGISTRATION" "true" + else + printf " ${GREEN}> PUBLIC_REGISTRATION already exists.${NC}\n" + fi +} + # Function to generate admin password generate_admin_password() { printf "${CYAN}> Generating admin password...${NC}\n" @@ -533,6 +550,80 @@ get_docker_compose_command() { echo "$base_command" } +# Add this new function for handling registration configuration +handle_registration_configuration() { + printf "${YELLOW}+++ Public Registration Configuration +++${NC}\n" + printf "\n" + + # Check if AliasVault is installed + if [ ! -f "docker-compose.yml" ]; then + printf "${RED}Error: AliasVault must be installed first.${NC}\n" + exit 1 + fi + + # Get current registration setting + CURRENT_SETTING=$(grep "^PUBLIC_REGISTRATION=" "$ENV_FILE" | cut -d '=' -f2) + + printf "${CYAN}About Public Registration:${NC}\n" + printf "Public registration allows new users to create their own accounts on your AliasVault instance.\n" + printf "When disabled, no new accounts can be created.\n" + printf "\n" + printf "${CYAN}Current Configuration:${NC}\n" + if [ "$CURRENT_SETTING" = "true" ]; then + printf "Public Registration: ${GREEN}Enabled${NC}\n" + else + printf "Public Registration: ${RED}Disabled${NC}\n" + fi + + printf "\n" + printf "Options:\n" + printf "1) Enable public registration\n" + printf "2) Disable public registration\n" + printf "3) Cancel\n" + printf "\n" + + read -p "Select an option [1-3]: " reg_option + + case $reg_option in + 1) + update_env_var "PUBLIC_REGISTRATION" "true" + printf "${GREEN}> Public registration has been enabled.${NC}\n" + + printf "\n${YELLOW}Warning: Docker containers need to be restarted to apply these changes.${NC}\n" + read -p "Restart now? (y/n): " restart_confirm + + if [ "$restart_confirm" != "y" ] && [ "$restart_confirm" != "Y" ]; then + printf "${YELLOW}Please restart manually to apply the changes.${NC}\n" + exit 0 + fi + + handle_restart + ;; + 2) + update_env_var "PUBLIC_REGISTRATION" "false" + printf "${YELLOW}> Public registration has been disabled.${NC}\n" + + printf "\n${YELLOW}Warning: Docker containers need to be restarted to apply these changes.${NC}\n" + read -p "Restart now? (y/n): " restart_confirm + + if [ "$restart_confirm" != "y" ] && [ "$restart_confirm" != "Y" ]; then + printf "${YELLOW}Please restart manually to apply the changes.${NC}\n" + exit 0 + fi + + handle_restart + ;; + 3) + printf "${YELLOW}Registration configuration cancelled.${NC}\n" + exit 0 + ;; + *) + printf "${RED}Invalid option selected.${NC}\n" + exit 1 + ;; + esac +} + # Function to handle initial installation or reinstallation handle_install() { local specified_version="$1" @@ -596,6 +687,8 @@ handle_build() { set_smtp_tls_enabled || { printf "${RED}> Failed to set SMTP TLS${NC}\n"; exit 1; } set_support_email || { printf "${RED}> Failed to set support email${NC}\n"; exit 1; } set_default_ports || { printf "${RED}> Failed to set default ports${NC}\n"; exit 1; } + set_public_registration || { printf "${RED}> Failed to set public registration${NC}\n"; exit 1; } + # Only generate admin password if not already set if ! grep -q "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" || [ -z "$(grep "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" | cut -d '=' -f2)" ]; then @@ -785,7 +878,6 @@ handle_ssl_configuration() { esac } -# Function to handle email server configuration # Function to handle email server configuration handle_email_configuration() { # Setup trap for Ctrl+C and other interrupts @@ -852,14 +944,6 @@ handle_email_configuration() { fi done - printf "\n${YELLOW}Warning: Docker containers need to be restarted to apply these changes.${NC}\n" - read -p "Continue with restart? (y/n): " restart_confirm - - if [ "$restart_confirm" != "y" ] && [ "$restart_confirm" != "Y" ]; then - printf "${YELLOW}Configuration cancelled.${NC}\n" - exit 0 - fi - # Update .env file and restart if ! update_env_var "PRIVATE_EMAIL_DOMAINS" "$new_domains"; then printf "${RED}Failed to update configuration.${NC}\n" @@ -867,6 +951,15 @@ handle_email_configuration() { fi printf "${GREEN}Email server configuration updated${NC}\n" + + printf "\n${YELLOW}Warning: Docker containers need to be restarted to apply these changes.${NC}\n" + read -p "Restart now? (y/n): " restart_confirm + + if [ "$restart_confirm" != "y" ] && [ "$restart_confirm" != "Y" ]; then + printf "${YELLOW}Please restart manually to apply the changes.${NC}\n" + exit 0 + fi + printf "Restarting AliasVault services...\n" if ! handle_restart; then @@ -1277,6 +1370,7 @@ handle_install_version() { set_smtp_tls_enabled || { printf "${RED}> Failed to set SMTP TLS${NC}\n"; exit 1; } set_support_email || { printf "${RED}> Failed to set support email${NC}\n"; exit 1; } set_default_ports || { printf "${RED}> Failed to set default ports${NC}\n"; exit 1; } + set_public_registration || { printf "${RED}> Failed to set public registration${NC}\n"; exit 1; } # Only generate admin password if not already set if ! grep -q "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" || [ -z "$(grep "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" | cut -d '=' -f2)" ]; then From 249efe54b058a913fe2f50630d03ba6e1f66e1fb Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 20 Dec 2024 16:06:15 +0100 Subject: [PATCH 2/5] Add public registration env flag check to api (#343) --- src/AliasVault.Api/Config.cs | 19 +++++++++++++++++++ .../Controllers/AuthController.cs | 9 ++++++++- src/AliasVault.Api/Program.cs | 8 ++++++++ .../Properties/launchSettings.json | 6 ++++-- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/AliasVault.Api/Config.cs diff --git a/src/AliasVault.Api/Config.cs b/src/AliasVault.Api/Config.cs new file mode 100644 index 00000000..9651ff4c --- /dev/null +++ b/src/AliasVault.Api/Config.cs @@ -0,0 +1,19 @@ +//----------------------------------------------------------------------- +// +// Copyright (c) lanedirt. All rights reserved. +// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. +// +//----------------------------------------------------------------------- + +namespace AliasVault.Api; + +/// +/// Configuration class for the Client project with values loaded from appsettings.json. +/// +public class Config +{ + /// + /// Gets or sets a value indicating whether public registration is enabled. + /// + public bool PublicRegistration { get; set; } +} diff --git a/src/AliasVault.Api/Controllers/AuthController.cs b/src/AliasVault.Api/Controllers/AuthController.cs index c7143e9d..44926e42 100644 --- a/src/AliasVault.Api/Controllers/AuthController.cs +++ b/src/AliasVault.Api/Controllers/AuthController.cs @@ -39,10 +39,11 @@ namespace AliasVault.Api.Controllers; /// IMemoryCache instance for persisting SRP values during multistep login process. /// ITimeProvider instance. This returns the time which can be mutated for testing. /// AuthLoggingService instance. This is used to log auth attempts to the database. +/// Config instance. [Route("v{version:apiVersion}/[controller]")] [ApiController] [ApiVersion("1")] -public class AuthController(IDbContextFactory dbContextFactory, UserManager userManager, SignInManager signInManager, IConfiguration configuration, IMemoryCache cache, ITimeProvider timeProvider, AuthLoggingService authLoggingService) : ControllerBase +public class AuthController(IDbContextFactory dbContextFactory, UserManager userManager, SignInManager signInManager, IConfiguration configuration, IMemoryCache cache, ITimeProvider timeProvider, AuthLoggingService authLoggingService, Config config) : ControllerBase { /// /// Error message for invalid username or password. @@ -331,6 +332,12 @@ public async Task Revoke([FromBody] TokenModel model) [HttpPost("register")] public async Task Register([FromBody] RegisterRequest model) { + // Check if public registration is disabled in the configuration. + if (!config.PublicRegistration) + { + return BadRequest(ServerValidationErrorResponse.Create(["New account registration is currently disabled on this server. Please contact the administrator."], 400)); + } + // Validate the username. var (isValid, errorMessage) = ValidateUsername(model.Username); if (!isValid) diff --git a/src/AliasVault.Api/Program.cs b/src/AliasVault.Api/Program.cs index 6ee4c57f..0e7a26b8 100644 --- a/src/AliasVault.Api/Program.cs +++ b/src/AliasVault.Api/Program.cs @@ -9,6 +9,7 @@ using System.Text; using AliasServerDb; using AliasServerDb.Configuration; +using AliasVault.Api; using AliasVault.Api.Jwt; using AliasVault.Auth; using AliasVault.Cryptography.Server; @@ -24,6 +25,13 @@ var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true); + +var config = new Config(); +var publicRegistration = Environment.GetEnvironmentVariable("PUBLIC_REGISTRATION") ?? "false"; +config.PublicRegistration = bool.Parse(publicRegistration); + +builder.Services.AddSingleton(config); + builder.Services.ConfigureLogging(builder.Configuration, Assembly.GetExecutingAssembly().GetName().Name!, "../../logs"); builder.Services.AddAliasVaultDataProtection("AliasVault.Api"); diff --git a/src/AliasVault.Api/Properties/launchSettings.json b/src/AliasVault.Api/Properties/launchSettings.json index cee60d3d..7b7ebc0c 100644 --- a/src/AliasVault.Api/Properties/launchSettings.json +++ b/src/AliasVault.Api/Properties/launchSettings.json @@ -7,7 +7,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "JWT_KEY": "12345678901234567890123456789012", - "DATA_PROTECTION_CERT_PASS": "Development" + "DATA_PROTECTION_CERT_PASS": "Development", + "PUBLIC_REGISTRATION": "true" }, "dotnetRunMessages": true, "applicationUrl": "http://0.0.0.0:5092" @@ -19,7 +20,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "JWT_KEY": "12345678901234567890123456789012", - "DATA_PROTECTION_CERT_PASS": "Development" + "DATA_PROTECTION_CERT_PASS": "Development", + "PUBLIC_REGISTRATION": "true" }, "dotnetRunMessages": true, "applicationUrl": "https://0.0.0.0:7223" From a7a7d6d82b8cd395158c52a741db06cfb83db40e Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 20 Dec 2024 16:51:51 +0100 Subject: [PATCH 3/5] Rename public registration enabled flag (#343) --- install.sh | 8 ++++---- src/AliasVault.Api/Config.cs | 2 +- src/AliasVault.Api/Controllers/AuthController.cs | 2 +- src/AliasVault.Api/Program.cs | 4 ++-- src/AliasVault.Api/Properties/launchSettings.json | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 6b404b09..f01250d2 100755 --- a/install.sh +++ b/install.sh @@ -372,11 +372,11 @@ set_support_email() { } set_public_registration() { - printf "${CYAN}> Checking PUBLIC_REGISTRATION...${NC}\n" - if ! grep -q "^PUBLIC_REGISTRATION=" "$ENV_FILE" || [ -z "$(grep "^PUBLIC_REGISTRATION=" "$ENV_FILE" | cut -d '=' -f2)" ]; then - update_env_var "PUBLIC_REGISTRATION" "true" + printf "${CYAN}> Checking PUBLIC_REGISTRATION_ENABLED...${NC}\n" + if ! grep -q "^PUBLIC_REGISTRATION_ENABLED=" "$ENV_FILE" || [ -z "$(grep "^PUBLIC_REGISTRATION_ENABLED=" "$ENV_FILE" | cut -d '=' -f2)" ]; then + update_env_var "PUBLIC_REGISTRATION_ENABLED" "true" else - printf " ${GREEN}> PUBLIC_REGISTRATION already exists.${NC}\n" + printf " ${GREEN}> PUBLIC_REGISTRATION_ENABLED already exists.${NC}\n" fi } diff --git a/src/AliasVault.Api/Config.cs b/src/AliasVault.Api/Config.cs index 9651ff4c..a724e4d9 100644 --- a/src/AliasVault.Api/Config.cs +++ b/src/AliasVault.Api/Config.cs @@ -15,5 +15,5 @@ public class Config /// /// Gets or sets a value indicating whether public registration is enabled. /// - public bool PublicRegistration { get; set; } + public bool PublicRegistrationEnabled { get; set; } } diff --git a/src/AliasVault.Api/Controllers/AuthController.cs b/src/AliasVault.Api/Controllers/AuthController.cs index 44926e42..df168c1d 100644 --- a/src/AliasVault.Api/Controllers/AuthController.cs +++ b/src/AliasVault.Api/Controllers/AuthController.cs @@ -333,7 +333,7 @@ public async Task Revoke([FromBody] TokenModel model) public async Task Register([FromBody] RegisterRequest model) { // Check if public registration is disabled in the configuration. - if (!config.PublicRegistration) + if (!config.PublicRegistrationEnabled) { return BadRequest(ServerValidationErrorResponse.Create(["New account registration is currently disabled on this server. Please contact the administrator."], 400)); } diff --git a/src/AliasVault.Api/Program.cs b/src/AliasVault.Api/Program.cs index 0e7a26b8..95b3c69e 100644 --- a/src/AliasVault.Api/Program.cs +++ b/src/AliasVault.Api/Program.cs @@ -27,8 +27,8 @@ builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true); var config = new Config(); -var publicRegistration = Environment.GetEnvironmentVariable("PUBLIC_REGISTRATION") ?? "false"; -config.PublicRegistration = bool.Parse(publicRegistration); +var publicRegistrationEnabled = Environment.GetEnvironmentVariable("PUBLIC_REGISTRATION_ENABLED") ?? "false"; +config.PublicRegistrationEnabled = bool.Parse(publicRegistrationEnabled); builder.Services.AddSingleton(config); diff --git a/src/AliasVault.Api/Properties/launchSettings.json b/src/AliasVault.Api/Properties/launchSettings.json index 7b7ebc0c..687660e8 100644 --- a/src/AliasVault.Api/Properties/launchSettings.json +++ b/src/AliasVault.Api/Properties/launchSettings.json @@ -8,7 +8,7 @@ "ASPNETCORE_ENVIRONMENT": "Development", "JWT_KEY": "12345678901234567890123456789012", "DATA_PROTECTION_CERT_PASS": "Development", - "PUBLIC_REGISTRATION": "true" + "PUBLIC_REGISTRATION_ENABLED": "true" }, "dotnetRunMessages": true, "applicationUrl": "http://0.0.0.0:5092" @@ -21,7 +21,7 @@ "ASPNETCORE_ENVIRONMENT": "Development", "JWT_KEY": "12345678901234567890123456789012", "DATA_PROTECTION_CERT_PASS": "Development", - "PUBLIC_REGISTRATION": "true" + "PUBLIC_REGISTRATION_ENABLED": "true" }, "dotnetRunMessages": true, "applicationUrl": "https://0.0.0.0:7223" From 07dd90a705a221366d01a656e36f99f46ad8becc Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 20 Dec 2024 16:52:05 +0100 Subject: [PATCH 4/5] Add public registration enabled check to client (#343) --- src/AliasVault.Client/Auth/Pages/Login.razor | 10 +++++++--- src/AliasVault.Client/Auth/Pages/Start.razor | 10 +++++++--- src/AliasVault.Client/Config.cs | 5 +++++ src/AliasVault.Client/entrypoint.sh | 3 +++ src/AliasVault.Client/wwwroot/appsettings.json | 3 ++- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/AliasVault.Client/Auth/Pages/Login.razor b/src/AliasVault.Client/Auth/Pages/Login.razor index 9c3fc623..ef507f00 100644 --- a/src/AliasVault.Client/Auth/Pages/Login.razor +++ b/src/AliasVault.Client/Auth/Pages/Login.razor @@ -1,6 +1,7 @@ @page "/user/login" @inherits AliasVault.Client.Auth.Pages.Base.LoginBase @layout Auth.Layout.MainLayout +@inject Config Config @attribute [AllowAnonymous] @using System.Text.Json @using AliasVault.Shared.Models.WebApi.Auth @@ -103,9 +104,12 @@ else -
- No account yet? Create new vault -
+ @if (Config.PublicRegistrationEnabled) + { +
+ No account yet? Create new vault +
+ } } diff --git a/src/AliasVault.Client/Auth/Pages/Start.razor b/src/AliasVault.Client/Auth/Pages/Start.razor index 94df2ab9..2e44412e 100644 --- a/src/AliasVault.Client/Auth/Pages/Start.razor +++ b/src/AliasVault.Client/Auth/Pages/Start.razor @@ -2,6 +2,7 @@ @using AliasVault.Client.Auth.Components @inherits AliasVault.Client.Auth.Pages.Base.LoginBase @layout Auth.Layout.EmptyLayout +@inject Config Config @attribute [AllowAnonymous]
@@ -22,9 +23,12 @@ Your Privacy. Protected.

- - Create new vault - + @if (Config.PublicRegistrationEnabled) + { + + Create new vault + + } Log in with existing account diff --git a/src/AliasVault.Client/Config.cs b/src/AliasVault.Client/Config.cs index 1295bd48..bbd6b146 100644 --- a/src/AliasVault.Client/Config.cs +++ b/src/AliasVault.Client/Config.cs @@ -62,4 +62,9 @@ public class Config /// Gets or sets the support email address that users can contact for password recovery. ///
public string? SupportEmail { get; set; } + + /// + /// Gets or sets a value indicating whether public registration is enabled. + /// + public bool PublicRegistrationEnabled { get; set; } } diff --git a/src/AliasVault.Client/entrypoint.sh b/src/AliasVault.Client/entrypoint.sh index 6da3fa60..a07a5dab 100755 --- a/src/AliasVault.Client/entrypoint.sh +++ b/src/AliasVault.Client/entrypoint.sh @@ -41,5 +41,8 @@ else sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"\"|g" /usr/share/nginx/html/appsettings.json fi +# Update public registration enabled in appsettings.json +sed -i "s|\"PublicRegistrationEnabled\": \".*\"|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\"|g" /usr/share/nginx/html/appsettings.json + # Start the application nginx -g "daemon off;" diff --git a/src/AliasVault.Client/wwwroot/appsettings.json b/src/AliasVault.Client/wwwroot/appsettings.json index 83bc6ece..22cb2d05 100644 --- a/src/AliasVault.Client/wwwroot/appsettings.json +++ b/src/AliasVault.Client/wwwroot/appsettings.json @@ -1,5 +1,6 @@ { "ApiUrl": "http://localhost:5092", "PrivateEmailDomains": ["example.tld"], - "SupportEmail": "support@example.tld" + "SupportEmail": "support@example.tld", + "PublicRegistrationEnabled": "true" } From 50853bf0111193c38fff610744dbb67a2f2129ac Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 20 Dec 2024 17:30:28 +0100 Subject: [PATCH 5/5] Update tests (#343) --- .../Common/ClientPlaywrightTest.cs | 26 +++++++------------ .../WebApplicationApiFactoryFixture.cs | 1 + 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs index f2b0be4a..87927c33 100644 --- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs +++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs @@ -96,21 +96,24 @@ protected override async Task SetupEnvironment() // Intercept Blazor WASM app requests to override appsettings.json string[] privateEmailDomains = ["example.tld", "example2.tld"]; + var appSettings = new + { + ApiUrl = ApiBaseUrl.TrimEnd('/'), + PrivateEmailDomains = privateEmailDomains, + PublicRegistrationEnabled = "true", + CryptographyOverrideType = "Argon2Id", + CryptographyOverrideSettings = "{\"DegreeOfParallelism\":1,\"MemorySize\":1024,\"Iterations\":1}", + }; await Context.RouteAsync( "**/appsettings.json", async route => { - var response = new - { - ApiUrl = ApiBaseUrl.TrimEnd('/'), - PrivateEmailDomains = privateEmailDomains, - }; await route.FulfillAsync( new RouteFulfillOptions { ContentType = "application/json", - Body = System.Text.Json.JsonSerializer.Serialize(response), + Body = System.Text.Json.JsonSerializer.Serialize(appSettings), }); }); @@ -118,20 +121,11 @@ await Context.RouteAsync( "**/appsettings.Development.json", async route => { - var response = new - { - ApiUrl = ApiBaseUrl.TrimEnd('/'), - PrivateEmailDomains = privateEmailDomains, - - // Override encryption settings for faster testing. - CryptographyOverrideType = "Argon2Id", - CryptographyOverrideSettings = "{\"DegreeOfParallelism\":1,\"MemorySize\":1024,\"Iterations\":1}", - }; await route.FulfillAsync( new RouteFulfillOptions { ContentType = "application/json", - Body = System.Text.Json.JsonSerializer.Serialize(response), + Body = System.Text.Json.JsonSerializer.Serialize(appSettings), }); }); diff --git a/src/Tests/AliasVault.E2ETests/Infrastructure/WebApplicationApiFactoryFixture.cs b/src/Tests/AliasVault.E2ETests/Infrastructure/WebApplicationApiFactoryFixture.cs index b7a5cfc2..b7103104 100644 --- a/src/Tests/AliasVault.E2ETests/Infrastructure/WebApplicationApiFactoryFixture.cs +++ b/src/Tests/AliasVault.E2ETests/Infrastructure/WebApplicationApiFactoryFixture.cs @@ -121,6 +121,7 @@ private static void SetEnvironmentVariables() { Environment.SetEnvironmentVariable("JWT_KEY", "12345678901234567890123456789012"); Environment.SetEnvironmentVariable("DATA_PROTECTION_CERT_PASS", "Development"); + Environment.SetEnvironmentVariable("PUBLIC_REGISTRATION_ENABLED", "true"); } ///