Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update docker compose (#44)
Leendert de Borst943f16789f0e
diff --git a/database/AliasClientDb/AliasClientDb.csproj b/database/AliasClientDb/AliasClientDb.csprojindex 7e5da0b6c..07cbd355f 100644--- a/database/AliasClientDb/AliasClientDb.csproj+++ b/database/AliasClientDb/AliasClientDb.csproj@@ -6,6 +6,16 @@<Nullable>enable</Nullable></PropertyGroup>+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">+ <DocumentationFile>bin\Debug\net8.0\AliasClientDb.xml</DocumentationFile>+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>+ </PropertyGroup>++ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">+ <DebugSymbols>true</DebugSymbols>+ <DocumentationFile>bin\Release\net8.0\AliasClientDb.xml</DocumentationFile>+ </PropertyGroup>+<ItemGroup><PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" /><PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">diff --git a/src/AliasVault.WebApp/Dockerfile b/src/AliasVault.WebApp/Dockerfileindex 400db26ea..92847f419 100644--- a/src/AliasVault.WebApp/Dockerfile+++ b/src/AliasVault.WebApp/Dockerfile@@ -7,6 +7,9 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS buildARG BUILD_CONFIGURATION=ReleaseWORKDIR /src+# Install Python which is required by the WebAssembly tools+RUN apt-get update && apt-get install -y python3+# Install the WebAssembly toolsRUN dotnet workload install wasm-toolsdiff --git a/src/AliasVault.WebApp/Services/AliasClientDbService.cs b/src/AliasVault.WebApp/Services/AliasClientDbService.csindex e88d9b265..47902ea0b 100644--- a/src/AliasVault.WebApp/Services/AliasClientDbService.cs+++ b/src/AliasVault.WebApp/Services/AliasClientDbService.cs@@ -5,10 +5,9 @@// </copyright>//------------------------------------------------------------------------using System.Data;-namespace AliasVault.WebApp.Services;+using System.Data;using System.Net.Http.Json;using AliasClientDb;using AliasVault.Shared.Models.WebApi;@@ -135,6 +134,69 @@ public class AliasClientDbService}}+ private static async Task ImportDbContextFromBase64Async(AliasClientDbContext dbContext, string base64String)+ {+ var bytes = Convert.FromBase64String(base64String);+ var tempFileName = Path.GetRandomFileName();+ await File.WriteAllBytesAsync(tempFileName, bytes);++ using (var connection = new SqliteConnection(dbContext.Database.GetDbConnection().ConnectionString))+ {+ await connection.OpenAsync();+ using (var command = connection.CreateCommand())+ {+ // Drop all tables in the original database+ command.CommandText = @"+ SELECT 'DELETE FROM ' || name || ';'+ FROM sqlite_master+ WHERE type = 'table' AND name NOT LIKE 'sqlite_%';";+ var dropTableCommands = new List<string>();+ using (var reader = await command.ExecuteReaderAsync())+ {+ while (await reader.ReadAsync())+ {+ dropTableCommands.Add(reader.GetString(0));+ }+ }++ foreach (var dropTableCommand in dropTableCommands)+ {+ command.CommandText = dropTableCommand;+ await command.ExecuteNonQueryAsync();+ }++ // Attach the imported database and copy tables+ command.CommandText = "ATTACH DATABASE @fileName AS importDb";+ command.Parameters.Add(new SqliteParameter("@fileName", tempFileName));+ await command.ExecuteNonQueryAsync();++ command.CommandText = @"+ SELECT 'INSERT INTO main.' || name || ' SELECT * FROM importDb.' || name || ';'+ FROM sqlite_master+ WHERE type = 'table' AND name NOT LIKE 'sqlite_%';";+ var tableInsertCommands = new List<string>();+ using (var reader = await command.ExecuteReaderAsync())+ {+ while (await reader.ReadAsync())+ {+ tableInsertCommands.Add(reader.GetString(0));+ }+ }++ foreach (var tableInsertCommand in tableInsertCommands)+ {+ command.CommandText = tableInsertCommand;+ await command.ExecuteNonQueryAsync();+ }++ command.CommandText = "DETACH DATABASE importDb";+ await command.ExecuteNonQueryAsync();+ }+ }++ File.Delete(tempFileName);+ }+private async Task InitializeDatabaseAsync(){// Create a new in-memory database.@@ -235,67 +297,4 @@ public class AliasClientDbServicereturn false;}}-- private async Task ImportDbContextFromBase64Async(AliasClientDbContext dbContext, string base64String)- {- var bytes = Convert.FromBase64String(base64String);- var tempFileName = Path.GetRandomFileName();- await File.WriteAllBytesAsync(tempFileName, bytes);-- using (var connection = new SqliteConnection(dbContext.Database.GetDbConnection().ConnectionString))- {- await connection.OpenAsync();- using (var command = connection.CreateCommand())- {- // Drop all tables in the original database- command.CommandText = @"- SELECT 'DELETE FROM ' || name || ';'- FROM sqlite_master- WHERE type = 'table' AND name NOT LIKE 'sqlite_%';";- var dropTableCommands = new List<string>();- using (var reader = await command.ExecuteReaderAsync())- {- while (await reader.ReadAsync())- {- dropTableCommands.Add(reader.GetString(0));- }- }-- foreach (var dropTableCommand in dropTableCommands)- {- command.CommandText = dropTableCommand;- await command.ExecuteNonQueryAsync();- }-- // Attach the imported database and copy tables- command.CommandText = "ATTACH DATABASE @fileName AS importDb";- command.Parameters.Add(new SqliteParameter("@fileName", tempFileName));- await command.ExecuteNonQueryAsync();-- command.CommandText = @"- SELECT 'INSERT INTO main.' || name || ' SELECT * FROM importDb.' || name || ';'- FROM sqlite_master- WHERE type = 'table' AND name NOT LIKE 'sqlite_%';";- var tableInsertCommands = new List<string>();- using (var reader = await command.ExecuteReaderAsync())- {- while (await reader.ReadAsync())- {- tableInsertCommands.Add(reader.GetString(0));- }- }-- foreach (var tableInsertCommand in tableInsertCommands)- {- command.CommandText = tableInsertCommand;- await command.ExecuteNonQueryAsync();- }-- command.CommandText = "DETACH DATABASE importDb";- await command.ExecuteNonQueryAsync();- }- }-- File.Delete(tempFileName);- }}