Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add .env for JWT keys, minor refactoring (#33)
Leendert de Borst210f4b3c9e67
diff --git a/.env.example b/.env.examplenew file mode 100644index 000000000..0c875568f--- /dev/null+++ b/.env.example@@ -0,0 +1 @@+JWT_Key=diff --git a/README.md b/README.mdindex 8feae2581..a929a1a34 100644--- a/README.md+++ b/README.md@@ -1,48 +1,56 @@-<div align="center">--<h1>AliasVault</h1>--[<img src="https://img.shields.io/github/v/release/lanedirt/AliasVault?include_prereleases&logo=github">](https://github.com/lanedirt/OGameX/releases)-[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/docker-compose-build.yml?label=docker-compose%20build">](https://github.com/lanedirt/AliasVault/actions/workflows/docker-compose-build.yml)-[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/dotnet-build-run-tests.yml?label=unit tests">](https://github.com/lanedirt/AliasVault/actions/workflows/dotnet-build-run-tests.yml)-[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/dotnet-integration-tests.yml?label=e2e tests">](https://github.com/lanedirt/AliasVault/actions/workflows/dotnet-integration-tests.yml)-[<img src="https://img.shields.io/sonar/coverage/lanedirt_AliasVault?server=https%3A%2F%2Fsonarcloud.io&label=test code coverage">](https://sonarcloud.io/summary/new_code?id=lanedirt_AliasVault)-[<img src="https://img.shields.io/sonar/quality_gate/lanedirt_AliasVault?server=https%3A%2F%2Fsonarcloud.io&label=sonarcloud&logo=sonarcloud">](https://sonarcloud.io/summary/new_code?id=lanedirt_AliasVault)-</div>--> Disclaimer: This repository is currently in an alpha state and is NOT ready for production use. Critical features, such as encryption, are not yet fully implemented. AliasVault is a work in progress and as of this moment serves as a research playground. Users are welcome to explore and use this project, but please be aware that there are no guarantees regarding its security or stability. Use at your own risk!--AliasVault is an open-source password manager that can generate virtual identities complete with virtual email addresses. AliasVault can be self-hosted on your own server with Docker, providing a secure and private solution for managing your online identities and passwords.--## Features-- Password Management: Securely store and manage your passwords.-- Virtual Identities: Generate virtual identities with virtual (working) email addresses.-- Data Protection: Ensures that all sensitive data is encrypted and securely stored.-- User Authentication: Secure login and user management functionalities.--## Installation--1. Clone this repository.--```bash-git clone [URL]-```--2. Run the app via Docker:--```bash-docker compose up -d --build --force-recreate-```--The app will be available at http://localhost:80----## Credits-The following libraries and frameworks are used in this project:--- [ASP.NET Core](https://dotnet.microsoft.com/apps/aspnet) - An open-source framework for building modern, cloud-based, internet-connected applications.-- [Blazor](https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor) - A framework for building interactive web UIs using C# instead of JavaScript.-- [Tailwind CSS](https://tailwindcss.com/) - A utility-first CSS framework for rapidly building custom designs.-- [Flowbite](https://flowbite.com/) - A free and open-source UI component library.-- [Konscious.Security.Cryptography](https://github.com/kmaragon/Konscious.Security.Cryptography) - A .NET library that implements Argon2id, a memory-hard password hashing algorithm.+<div align="center">++<h1>AliasVault</h1>++[<img src="https://img.shields.io/github/v/release/lanedirt/AliasVault?include_prereleases&logo=github">](https://github.com/lanedirt/OGameX/releases)+[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/docker-compose-build.yml?label=docker-compose%20build">](https://github.com/lanedirt/AliasVault/actions/workflows/docker-compose-build.yml)+[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/dotnet-build-run-tests.yml?label=unit tests">](https://github.com/lanedirt/AliasVault/actions/workflows/dotnet-build-run-tests.yml)+[<img src="https://img.shields.io/github/actions/workflow/status/lanedirt/AliasVault/dotnet-integration-tests.yml?label=e2e tests">](https://github.com/lanedirt/AliasVault/actions/workflows/dotnet-integration-tests.yml)+[<img src="https://img.shields.io/sonar/coverage/lanedirt_AliasVault?server=https%3A%2F%2Fsonarcloud.io&label=test code coverage">](https://sonarcloud.io/summary/new_code?id=lanedirt_AliasVault)+[<img src="https://img.shields.io/sonar/quality_gate/lanedirt_AliasVault?server=https%3A%2F%2Fsonarcloud.io&label=sonarcloud&logo=sonarcloud">](https://sonarcloud.io/summary/new_code?id=lanedirt_AliasVault)+</div>++> Disclaimer: This repository is currently in an alpha state and is NOT ready for production use. Critical features, such as encryption, are not yet fully implemented. AliasVault is a work in progress and as of this moment serves as a research playground. Users are welcome to explore and use this project, but please be aware that there are no guarantees regarding its security or stability. Use at your own risk!++AliasVault is an open-source password manager that can generate virtual identities complete with virtual email addresses. AliasVault can be self-hosted on your own server with Docker, providing a secure and private solution for managing your online identities and passwords.++## Features+- **Password Management:** Securely store and manage your passwords.+- **Virtual Identities:** Generate virtual identities with virtual (working) email addresses that are assigned to one or more passwords.+- **Zero-knowledge architecture:** Ensures that all sensitive data is end-to-end encrypted on the client and stored in encrypted state on the database. The server never has access to your data.++## Installation++1. Clone this repository.++```bash+git clone https://github.com/lanedirt/AliasVault.git+```++2. Build and run the app via Docker:++```bash+docker compose up -d --build --force-recreate+```++### Note for first time build:+- When running the app for the first time, it may take a few minutes to build the Docker image.+- Two files will be created during build (if they don't yet exist):+ - **Database:** `./database/aliasdb.sqlite`+ - This SQLite file contains the database and in it all (encrypted) password vaults. It should be kept secure and not shared.+ - **Encryption secrets:** `./.env`+ - This file contains the JWT secret that is used to generate user access tokens for login and should be kept secret.++++After the Docker containers have started the app will be available at http://localhost:80++## Tech stack / credits+The following technologies, frameworks and libraries are used in this project:++- [C#](https://docs.microsoft.com/en-us/dotnet/csharp/) - A simple, modern, object-oriented, and type-safe programming language.+- [ASP.NET Core](https://dotnet.microsoft.com/apps/aspnet) - An open-source framework for building modern, cloud-based, internet-connected applications.+- [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) - A lightweight, extensible, open-source and cross-platform version of the popular Entity Framework data access technology. - [Blazor WASM](https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor) - A framework for building interactive web UIs using C# instead of JavaScript. It's a single-page app framework that runs in the browser via WebAssembly. - [Docker](https://www.docker.com/) - A platform for building, sharing, and running containerized applications. - [SQLite](https://www.sqlite.org/index.html) - A C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine.+- [Tailwind CSS](https://tailwindcss.com/) - A utility-first CSS framework for rapidly building custom designs.+- [Flowbite](https://flowbite.com/) - A free and open-source UI component library based on Tailwind CSS.+- [Konscious.Security.Cryptography](https://github.com/kmaragon/Konscious.Security.Cryptography) - A .NET library that implements Argon2id, a memory-hard password hashing algorithm.diff --git a/docker-compose.yml b/docker-compose.ymlindex a22f77391..5b83d0057 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -30,4 +30,6 @@ services:- "81:8081"volumes:- ./database:/database+ env_file:+ - .envrestart: alwaysdiff --git a/src/AliasDb/AliasDbContext.cs b/src/AliasDb/AliasDbContext.csindex eac1c9066..50aa1e59e 100644--- a/src/AliasDb/AliasDbContext.cs+++ b/src/AliasDb/AliasDbContext.cs@@ -60,16 +60,17 @@ public class AliasDbContext : IdentityDbContext/// <summary>/// The OnModelCreating method./// </summary>- /// <param name="modelBuilder">ModelBuilder instance.</param>- protected override void OnModelCreating(ModelBuilder modelBuilder)+ /// <param name="builder">ModelBuilder instance.</param>+ protected override void OnModelCreating(ModelBuilder builder){- base.OnModelCreating(modelBuilder);- foreach (var entity in modelBuilder.Model.GetEntityTypes())+ base.OnModelCreating(builder);+ foreach (var entity in builder.Model.GetEntityTypes()){foreach (var property in entity.GetProperties()){- // TODO: This is a workaround for SQLite. Add conditional check if SQLite is used.- // TODO: SQL server doesn't need this override.+ // NOTE: This is a workaround for SQLite. Add conditional check if SQLite is used.+ // NOTE: SQL server doesn't need this override.+// SQLite does not support varchar(max) so we use TEXT.if (property.ClrType == typeof(string) && property.GetMaxLength() == null){@@ -79,42 +80,42 @@ public class AliasDbContext : IdentityDbContext}// Configure Identity - Login relationship- modelBuilder.Entity<Login>()+ builder.Entity<Login>().HasOne(l => l.Identity).WithMany().HasForeignKey(l => l.IdentityId).OnDelete(DeleteBehavior.Cascade);// Configure the Login - UserId entity- modelBuilder.Entity<Login>()+ builder.Entity<Login>().HasOne(p => p.User).WithMany().HasForeignKey(p => p.UserId).IsRequired();// Configure Login - Service relationship- modelBuilder.Entity<Login>()+ builder.Entity<Login>().HasOne(l => l.Service).WithMany().HasForeignKey(l => l.ServiceId).OnDelete(DeleteBehavior.Cascade);// Configure Login - Password relationship- modelBuilder.Entity<Login>()+ builder.Entity<Login>().HasMany(l => l.Passwords).WithOne(p => p.Login).HasForeignKey(p => p.LoginId).OnDelete(DeleteBehavior.Cascade);// Configure Identity - DefaultPassword relationship- modelBuilder.Entity<Identity>()+ builder.Entity<Identity>().HasOne(i => i.DefaultPassword).WithMany().HasForeignKey(i => i.DefaultPasswordId).OnDelete(DeleteBehavior.SetNull);// Configure the User - AspNetUserRefreshToken entity- modelBuilder.Entity<AspNetUserRefreshToken>()+ builder.Entity<AspNetUserRefreshToken>().HasOne(p => p.User).WithMany().HasForeignKey(p => p.UserId)diff --git a/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.cs b/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.csindex faab122af..ecf246297 100644--- a/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.cs+++ b/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.cs@@ -13,20 +13,21 @@ using System.Text.Json;/// </summary>public class FigIdentityGenerator : IIdentityGenerator{- private static readonly HttpClient HttpClient = new();- private static readonly string Url = "https://api.identiteitgenerator.nl/generate/identity";+ private static readonly HttpClient _httpClient = new();+ private static readonly string _url = "https://api.identiteitgenerator.nl/generate/identity";+ private static readonly JsonSerializerOptions _jsonSerializerOptions = new()+ {+ PropertyNameCaseInsensitive = true,+ };/// <inheritdoc/>public async Task<Identity.Models.Identity> GenerateRandomIdentityAsync(){- var response = await HttpClient.GetAsync(Url);+ var response = await _httpClient.GetAsync(_url);response.EnsureSuccessStatusCode();var json = await response.Content.ReadAsStringAsync();- var identity = JsonSerializer.Deserialize<Identity.Models.Identity>(json, new JsonSerializerOptions- {- PropertyNameCaseInsensitive = true,- });+ var identity = JsonSerializer.Deserialize<Identity.Models.Identity>(json, _jsonSerializerOptions);if (identity is null){diff --git a/src/AliasVault.Api/Controllers/AuthController.cs b/src/AliasVault.Api/Controllers/AuthController.csindex 934ebd7fe..56152228b 100644--- a/src/AliasVault.Api/Controllers/AuthController.cs+++ b/src/AliasVault.Api/Controllers/AuthController.cs@@ -42,7 +42,7 @@ public class AuthController(AliasDbContext context, UserManager<IdentityUser> usvar user = await userManager.FindByEmailAsync(model.Email);if (user != null && await userManager.CheckPasswordAsync(user, model.Password)){- var tokenModel = await GenerateNewTokenForUser(user);+ var tokenModel = await GenerateNewTokensForUser(user);return Ok(tokenModel);}@@ -151,7 +151,7 @@ public class AuthController(AliasDbContext context, UserManager<IdentityUser> usawait signInManager.SignInAsync(user, isPersistent: false);// Return the token.- var tokenModel = await GenerateNewTokenForUser(user);+ var tokenModel = await GenerateNewTokensForUser(user);return Ok(tokenModel);}@@ -159,6 +159,32 @@ public class AuthController(AliasDbContext context, UserManager<IdentityUser> usreturn BadRequest(ServerValidationErrorResponse.Create(errors, 400));}+ /// <summary>+ /// Generate a device identifier based on request headers. This is used to associate refresh tokens+ /// with a specific device for a specific user.+ ///+ /// NOTE: current implementation means that only one refresh token can be valid for a+ /// specific user/device combo at a time. The identifier generation could be made more unique in the future+ /// to prevent any unwanted conflicts.+ /// </summary>+ /// <param name="request">The HttpRequest instance for the request that the client used.</param>+ /// <returns>Unique device identifier as string.</returns>+ private static string GenerateDeviceIdentifier(HttpRequest request)+ {+ var userAgent = request.Headers.UserAgent.ToString();+ var acceptLanguage = request.Headers.AcceptLanguage.ToString();++ var rawIdentifier = $"{userAgent}|{acceptLanguage}";+ return rawIdentifier;+ }++ /// <summary>+ /// Generate a Jwt access token for a user. This token is used to authenticate the user for a limited time+ /// and is short-lived by design. With the separate refresh token, the user can request a new access token+ /// when this access token expires.+ /// </summary>+ /// <param name="user">The user to generate the Jwt access token for.</param>+ /// <returns>Access token as string.</returns>private string GenerateJwtToken(IdentityUser user){var claims = new List<Claim>@@ -176,12 +202,17 @@ public class AuthController(AliasDbContext context, UserManager<IdentityUser> usissuer: configuration["Jwt:Issuer"] ?? string.Empty,audience: configuration["Jwt:Issuer"] ?? string.Empty,claims: claims,- expires: DateTime.Now.AddSeconds(15),+ expires: DateTime.Now.AddMinutes(10),signingCredentials: creds);return new JwtSecurityTokenHandler().WriteToken(token);}+ /// <summary>+ /// Generate a refresh token for a user. This token is used to request a new access token when the current+ /// access token expires. The refresh token is long-lived by design.+ /// </summary>+ /// <returns>Random string to be used as refresh token.</returns>private string GenerateRefreshToken(){var randomNumber = new byte[32];@@ -212,17 +243,13 @@ public class AuthController(AliasDbContext context, UserManager<IdentityUser> usreturn principal;}- private string GenerateDeviceIdentifier(HttpRequest request)- {- // TODO: Add more headers to the device identifier or let client send a unique identifier instead.- var userAgent = request.Headers.UserAgent.ToString();- var acceptLanguage = request.Headers.AcceptLanguage.ToString();-- var rawIdentifier = $"{userAgent}|{acceptLanguage}";- return rawIdentifier;- }-- private async Task<TokenModel> GenerateNewTokenForUser(IdentityUser user)+ /// <summary>+ /// Generates a new access and refresh token for a user and persists the refresh token+ /// to the database.+ /// </summary>+ /// <param name="user">The user to generate the tokens for.</param>+ /// <returns>TokenModel which includes new access and refresh token.</returns>+ private async Task<TokenModel> GenerateNewTokensForUser(IdentityUser user){var token = GenerateJwtToken(user);var refreshToken = GenerateRefreshToken();diff --git a/src/AliasVault.Api/Controllers/IdentityController.cs b/src/AliasVault.Api/Controllers/IdentityController.csindex f7fa6cf58..e42542ff2 100644--- a/src/AliasVault.Api/Controllers/IdentityController.cs+++ b/src/AliasVault.Api/Controllers/IdentityController.cs@@ -32,7 +32,7 @@ public class IdentityController(UserManager<IdentityUser> userManager) : Authentreturn Unauthorized();}- IIdentityGenerator identityGenerator = new FigIdentityGenerator();+ var identityGenerator = new FigIdentityGenerator();return Ok(await identityGenerator.GenerateRandomIdentityAsync());}}diff --git a/src/AliasVault.Api/Dockerfile b/src/AliasVault.Api/Dockerfileindex eb9f6d456..cdbea45c7 100644--- a/src/AliasVault.Api/Dockerfile+++ b/src/AliasVault.Api/Dockerfile@@ -14,17 +14,28 @@ COPY ["src/AliasVault.Shared/AliasVault.Shared.csproj", "src/AliasVault.Shared/"COPY ["src/AliasGenerators/AliasGenerators.csproj", "src/AliasGenerators/"]RUN dotnet restore "src/AliasVault.Api/AliasVault.Api.csproj"+# Copy .env.example to .env if .env does not exist+RUN test -f .env || cp .env.example .env++# Generate a random JWT key if not set+RUN if [ -z "$(grep ^JWT_KEY= .env | cut -d '=' -f2)" ]; then \+ echo "Generating JWT key..."; \+ JWT_KEY=$(openssl rand -base64 32); \+ sed -i "/^JWT_KEY=/c\JWT_KEY=${JWT_KEY}" .env; \+ dos2unix .env; \+fi+# Copy the rest of the application codeCOPY . .# Build the WebApi projectWORKDIR "/src/src/AliasVault.Api"-RUN dotnet build "AliasVault.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build+RUN dotnet build "AliasVault.Api.csproj" -c "$BUILD_CONFIGURATION" -o /app/build# Publish the application to the /app/publish directory in the containerFROM build AS publishARG BUILD_CONFIGURATION=Release-RUN dotnet publish "AliasVault.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false+RUN dotnet publish "AliasVault.Api.csproj" -c "$BUILD_CONFIGURATION" -o /app/publish /p:UseAppHost=false# Create the migration bundle# Install the Entity Framework Core CLI tool and run migrations to create the databasediff --git a/src/AliasVault.Api/Program.cs b/src/AliasVault.Api/Program.csindex 61902523a..fd132108a 100644--- a/src/AliasVault.Api/Program.cs+++ b/src/AliasVault.Api/Program.cs@@ -73,6 +73,12 @@ builder.Services.AddAuthentication(options =>options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;}).AddJwtBearer(options =>{+ var jwtKey = Environment.GetEnvironmentVariable("JWT_KEY");+ if (jwtKey is null)+ {+ throw new KeyNotFoundException("JWT_KEY environment variable is not set.");+ }+options.IncludeErrorDetails = true;options.TokenValidationParameters = new TokenValidationParameters{@@ -83,7 +89,7 @@ builder.Services.AddAuthentication(options =>ValidateIssuerSigningKey = true,ValidIssuer = configuration["Jwt:Issuer"],ValidAudience = configuration["Jwt:Issuer"],- IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:Key"] ?? string.Empty)),+ IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtKey)),ClockSkew = TimeSpan.Zero,};});diff --git a/src/AliasVault.Api/Properties/launchSettings.json b/src/AliasVault.Api/Properties/launchSettings.jsonindex 0bf065bbc..b3e6b7f8f 100644--- a/src/AliasVault.Api/Properties/launchSettings.json+++ b/src/AliasVault.Api/Properties/launchSettings.json@@ -1,33 +1,26 @@-{- "$schema": "http://json.schemastore.org/launchsettings.json",- "iisSettings": {- "windowsAuthentication": false,- "anonymousAuthentication": true,- "iisExpress": {- "applicationUrl": "http://localhost:39952",- "sslPort": 44368- }- },+{"profiles": {"http": {"commandName": "Project",- "dotnetRunMessages": true,"launchBrowser": true,"launchUrl": "swagger",- "applicationUrl": "http://localhost:5092","environmentVariables": {- "ASPNETCORE_ENVIRONMENT": "Development"- }+ "ASPNETCORE_ENVIRONMENT": "Development",+ "JWT_Key": "12345678901234567890123456789012"+ },+ "dotnetRunMessages": true,+ "applicationUrl": "http://localhost:5092"},"https": {"commandName": "Project",- "dotnetRunMessages": true,"launchBrowser": true,"launchUrl": "swagger",- "applicationUrl": "https://localhost:7223;http://localhost:5092","environmentVariables": {- "ASPNETCORE_ENVIRONMENT": "Development"- }+ "ASPNETCORE_ENVIRONMENT": "Development",+ "JWT_Key": "12345678901234567890123456789012"+ },+ "dotnetRunMessages": true,+ "applicationUrl": "https://localhost:7223;http://localhost:5092"},"IIS Express": {"commandName": "IISExpress",@@ -37,5 +30,14 @@"ASPNETCORE_ENVIRONMENT": "Development"}}+ },+ "$schema": "http://json.schemastore.org/launchsettings.json",+ "iisSettings": {+ "windowsAuthentication": false,+ "anonymousAuthentication": true,+ "iisExpress": {+ "applicationUrl": "http://localhost:39952",+ "sslPort": 44368+ }}-}+}\ No newline at end of filediff --git a/src/AliasVault.Api/appsettings.json b/src/AliasVault.Api/appsettings.jsonindex 1a553f714..6f504df52 100644--- a/src/AliasVault.Api/appsettings.json+++ b/src/AliasVault.Api/appsettings.json@@ -6,8 +6,7 @@}},"Jwt": {- "Key": "[[&lokl$4r<ak{f}4d#iv7>92i*)=sfo",- "Issuer": "YourIssuer"+ "Issuer": "AliasVault"},"ConnectionStrings": {"AliasDbContext": "Data Source=../../database/aliasdb.sqlite"diff --git a/src/AliasVault.Shared/Models/WebApi/ServerValidationErrorResponse.cs b/src/AliasVault.Shared/Models/WebApi/ServerValidationErrorResponse.csindex 86e7a004a..3ac8207a9 100644--- a/src/AliasVault.Shared/Models/WebApi/ServerValidationErrorResponse.cs+++ b/src/AliasVault.Shared/Models/WebApi/ServerValidationErrorResponse.cs@@ -84,7 +84,7 @@ public class ServerValidationErrorResponsereturn new ServerValidationErrorResponse{Type = "https://tools.ietf.org/html/rfc7231#section-6.5.1",- Title = errorArray.First(),+ Title = errorArray[0],Errors = errors,Status = status,TraceId = Guid.NewGuid().ToString(),diff --git a/src/AliasVault.WebApp/Components/Alerts/GlobalNotificationDisplay.razor b/src/AliasVault.WebApp/Components/Alerts/GlobalNotificationDisplay.razorindex 79afc9514..b8606ada2 100644--- a/src/AliasVault.WebApp/Components/Alerts/GlobalNotificationDisplay.razor+++ b/src/AliasVault.WebApp/Components/Alerts/GlobalNotificationDisplay.razor@@ -54,14 +54,14 @@var newMessages = GlobalNotificationService.GetMessagesForDisplay();foreach (var message in newMessages){- if (!Messages.Any(m => m.Key == message.Key && m.Value == message.Value))+ if (!Messages.Exists(m => m.Key == message.Key && m.Value == message.Value)){Messages.Add(message);}}// Remove messages that are no longer in the GlobalNotificationService and have already been displayed.- var messagesToRemove = Messages.Where(m => !newMessages.Any(nm => nm.Key == m.Key && nm.Value == m.Value)).ToList();+ var messagesToRemove = Messages.Where(m => !newMessages.Exists(nm => nm.Key == m.Key && nm.Value == m.Value)).ToList();foreach (var message in messagesToRemove){Messages.Remove(message);diff --git a/src/AliasVault.WebApp/Components/Breadcrumb.razor b/src/AliasVault.WebApp/Components/Breadcrumb.razorindex f06fc858e..573a3fa2d 100644--- a/src/AliasVault.WebApp/Components/Breadcrumb.razor+++ b/src/AliasVault.WebApp/Components/Breadcrumb.razor@@ -46,7 +46,7 @@{base.OnInitialized();// Remove first item if it is the home page- if (BreadcrumbItems.Any() && BreadcrumbItems.First().DisplayName == "Home")+ if (BreadcrumbItems.Any() && BreadcrumbItems[0].DisplayName == "Home"){BreadcrumbItems.RemoveAt(0);}diff --git a/src/AliasVault.WebApp/Components/CopyPasteFormRow.razor b/src/AliasVault.WebApp/Components/CopyPasteFormRow.razorindex 205d4b89f..5bffd0b62 100644--- a/src/AliasVault.WebApp/Components/CopyPasteFormRow.razor+++ b/src/AliasVault.WebApp/Components/CopyPasteFormRow.razor@@ -20,7 +20,7 @@[Parameter] public string Value { get; set; } = string.Empty;private bool _copied => ClipboardCopyService.GetCopiedId() == _inputId;- private string _inputId = Guid.NewGuid().ToString();+ private readonly string _inputId = Guid.NewGuid().ToString();protected override void OnInitialized(){diff --git a/src/AliasVault.WebApp/Components/ServerValidationErrors.razor b/src/AliasVault.WebApp/Components/ServerValidationErrors.razorindex 03f8d0712..c4061842e 100644--- a/src/AliasVault.WebApp/Components/ServerValidationErrors.razor+++ b/src/AliasVault.WebApp/Components/ServerValidationErrors.razor@@ -9,7 +9,7 @@}@code {- private List<string> _errors = [];+ private readonly List<string> _errors = [];/// <summary>/// Parses the response content and displays the server validation errors.diff --git a/src/AliasVault.WebApp/Dockerfile b/src/AliasVault.WebApp/Dockerfileindex 0a2bc5530..af87e34f7 100644--- a/src/AliasVault.WebApp/Dockerfile+++ b/src/AliasVault.WebApp/Dockerfile@@ -20,12 +20,12 @@ COPY . .# Build the WebApp projectWORKDIR "/src/src/AliasVault.WebApp"-RUN dotnet build "AliasVault.WebApp.csproj" -c $BUILD_CONFIGURATION -o /app/build+RUN dotnet build "AliasVault.WebApp.csproj" -c "$BUILD_CONFIGURATION" -o /app/build# Publish the WebApp projectFROM build AS publishARG BUILD_CONFIGURATION=Release-RUN dotnet publish "AliasVault.WebApp.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false+RUN dotnet publish "AliasVault.WebApp.csproj" -c "$BUILD_CONFIGURATION" -o /app/publish /p:UseAppHost=false# Final stage: start nginx and serve static html files that were published in the previous stageFROM nginx:alpine AS finaldiff --git a/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor b/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razorindex 28d2d8a5b..a444e5322 100644--- a/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor+++ b/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor@@ -6,6 +6,7 @@@using AliasGenerators.Implementations@using AliasGenerators.Password.Implementations@using AliasVault.Shared.Models.WebApi+@using System.Globalization@if (EditMode){@@ -254,7 +255,7 @@ elseObj.Identity.AddressState = identity.Address.State;Obj.Identity.AddressZipCode = identity.Address.ZipCode;Obj.Identity.AddressCountry = identity.Address.Country;- Obj.Identity.Hobbies = identity.Hobbies.First();+ Obj.Identity.Hobbies = identity.Hobbies[0];Obj.Identity.EmailPrefix = identity.EmailPrefix;Obj.Identity.PhoneMobile = identity.PhoneMobile;Obj.Identity.BankAccountIBAN = identity.BankAccountIBAN;@@ -291,7 +292,7 @@ else{try{- DateTime.Parse(Obj.Identity.BirthDate);+ DateTime.Parse(Obj.Identity.BirthDate, new CultureInfo("en-US"));}catch (Exception){diff --git a/src/AliasVault.WebApp/Pages/Aliases/View.razor b/src/AliasVault.WebApp/Pages/Aliases/View.razorindex b317e4ba0..7b0b2f38b 100644--- a/src/AliasVault.WebApp/Pages/Aliases/View.razor+++ b/src/AliasVault.WebApp/Pages/Aliases/View.razor@@ -155,7 +155,7 @@ elsereturn;}- AliasEmail = Alias?.Identity.EmailPrefix + "@landmail.nl";+ AliasEmail = Alias.Identity.EmailPrefix + "@landmail.nl";IsLoading = false;StateHasChanged();diff --git a/src/AliasVault.WebApp/wwwroot/js/dark-mode.js b/src/AliasVault.WebApp/wwwroot/js/dark-mode.jsindex 212580e7e..d84880f91 100644--- a/src/AliasVault.WebApp/wwwroot/js/dark-mode.js+++ b/src/AliasVault.WebApp/wwwroot/js/dark-mode.js@@ -39,16 +39,13 @@ function initDarkModeSwitcher() {document.documentElement.classList.remove('dark');localStorage.setItem('color-theme', 'light');}-- // if NOT set via local storage previously+ // if NOT set via local storage previously+ } else if (document.documentElement.classList.contains('dark')) {+ document.documentElement.classList.remove('dark');+ localStorage.setItem('color-theme', 'light');} else {- if (document.documentElement.classList.contains('dark')) {- document.documentElement.classList.remove('dark');- localStorage.setItem('color-theme', 'light');- } else {- document.documentElement.classList.add('dark');- localStorage.setItem('color-theme', 'dark');- }+ document.documentElement.classList.add('dark');+ localStorage.setItem('color-theme', 'dark');}document.dispatchEvent(event);diff --git a/src/Tests/AliasVault.E2ETests/Infrastructure/BlazorWasmAppManager.cs b/src/Tests/AliasVault.E2ETests/Infrastructure/BlazorWasmAppManager.csindex 17d83f6d6..64b3fa937 100644--- a/src/Tests/AliasVault.E2ETests/Infrastructure/BlazorWasmAppManager.cs+++ b/src/Tests/AliasVault.E2ETests/Infrastructure/BlazorWasmAppManager.cs@@ -77,7 +77,7 @@ public class BlazorWasmAppManager}}- private string GetBaseDirectory()+ private static string GetBaseDirectory(){string currentDir = Directory.GetCurrentDirectory();string baseDir = string.Empty;@@ -90,35 +90,8 @@ public class BlazorWasmAppManagerreturn baseDir;}- private async Task WaitForStartupAsync(int port)- {- // Wait for the application to start up- var started = false;- while (!started)- {- try- {- using (var client = new HttpClient())- {- var response = await client.GetAsync($"http://localhost:{port}");- started = response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.NotFound;- }- }- catch (Exception e)- {- await TestContext.Out.WriteLineAsync(e.Message);-- if (_blazorWasmErrors.Count > 0)- {- Assert.Fail($"WASM failed to start: {string.Join(Environment.NewLine, _blazorWasmErrors)}");- return;- }- }- }- }-#if WINDOWS- private void KillProcessAndChildrenWindows(int pid)+ private static void KillProcessAndChildrenWindows(int pid){var searcher = new ManagementObjectSearcher($"Select * From Win32_Process Where ParentProcessID={pid}");var managementObjects = searcher.Get();@@ -140,7 +113,7 @@ public class BlazorWasmAppManager}}#else- private void KillProcessAndChildrenUnix(int pid)+ private static void KillProcessAndChildrenUnix(int pid){try{@@ -178,4 +151,31 @@ public class BlazorWasmAppManager}}#endif++ private async Task WaitForStartupAsync(int port)+ {+ // Wait for the application to start up+ var started = false;+ while (!started)+ {+ try+ {+ using (var client = new HttpClient())+ {+ var response = await client.GetAsync($"http://localhost:{port}");+ started = response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.NotFound;+ }+ }+ catch (Exception e)+ {+ await TestContext.Out.WriteLineAsync(e.Message);++ if (_blazorWasmErrors.Count > 0)+ {+ Assert.Fail($"WASM failed to start: {string.Join(Environment.NewLine, _blazorWasmErrors)}");+ return;+ }+ }+ }+ }}