Skip to content

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

Update VaultKey database model (#2159)

Leendert de Borst957fe0a0e741
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx
index 2af8072e4..c4fd97cc2 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx
@@ -467,7 +467,7 @@ const Login: React.FC = () => {
* the mobile app predates the KEK/VEK model). Refresh the local wrapped-VEK cache so offline password unlock
* keeps working, then upgrade the received key to the VEK when it turns out to be the KEK.
*/
- await VaultKeyService.cacheWrappedVekFromServer(webApi);
+ await VaultKeyService.cacheEncryptedVekFromServer(webApi);
const mobileKey = await VaultKeyService.resolveStoredUnlockKey(result.decryptionKey);
// Store the encryption key and derivation params
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
index 29a6ced5a..c48eea586 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
@@ -582,7 +582,7 @@ const Unlock: React.FC = () => {
* the mobile app predates the KEK/VEK model). Refresh the local wrapped-VEK cache so offline password unlock
* keeps working, then upgrade the received key to the VEK when it turns out to be the KEK.
*/
- await VaultKeyService.cacheWrappedVekFromServer(webApi);
+ await VaultKeyService.cacheEncryptedVekFromServer(webApi);
const mobileKey = await VaultKeyService.resolveStoredUnlockKey(result.decryptionKey);
// Store the encryption key and derivation params
diff --git a/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts
index 6c9e9ff3e..adfdd8307 100644
--- a/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts
+++ b/apps/browser-extension/src/utils/dist/core/models/identity/index.d.ts
@@ -10,7 +10,6 @@ declare enum Gender {
/**
* A generated identity as returned by the Rust core identity generator
- * (JSON with camelCase fields).
*/
type Identity = {
firstName: string;
diff --git a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
index a5d0edf85..e278ffb66 100644
--- a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
+++ b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
@@ -443,15 +443,15 @@ type MobileLoginPollResponse = {
};
/**
- * Vault key response type (KEK/VEK model). Returned by GET /v2/VaultKey/{keyType}.
- * Carries the wrapped VEK plus the KEK derivation parameters so an authenticated client can derive the KEK from
+ * Vault key response type (KEK/VEK model). Returned by GET /v2/VaultKey/{type}.
+ * Carries the encrypted VEK plus the KEK derivation parameters so an authenticated client can derive the KEK from
* the unlock secret and unwrap the vault encryption key. The SRP verifier is never returned.
*/
type VaultKeyResponse = {
/** The unlock method type, e.g. "password". */
- keyType: string;
- /** The wrapped VEK: base64(IV ‖ ciphertext ‖ authTag) of the VEK encrypted with the KEK (AES-256-GCM). */
- wrappedVek: string;
+ type: string;
+ /** The encrypted VEK: base64(IV ‖ ciphertext ‖ authTag) of the VEK encrypted with the KEK (AES-256-GCM). */
+ encryptedVek: string;
/** The salt used for KEK derivation (same value as the SRP salt for the password key type). */
salt: string;
/** The key derivation type, e.g. "Argon2Id". */
@@ -460,10 +460,10 @@ type VaultKeyResponse = {
encryptionSettings: string;
};
/**
- * Envelope returned by GET /v2/VaultKey/{keyType} with HTTP 200. A null vaultKey means the user has no vault key
+ * Envelope returned by GET /v2/VaultKey/{type} with HTTP 200. A null vaultKey means the user has no vault key
* of the requested type (legacy user). An HTTP 404 on the endpoint itself means the server does not implement
* vault keys at all (older server version) and must be treated differently: fall back to any locally cached
- * wrapped VEK instead of assuming a legacy account.
+ * encrypted VEK instead of assuming a legacy account.
*/
type VaultKeyGetResponse = {
vaultKey: VaultKeyResponse | null;
diff --git a/apps/mobile-app/utils/dist/core/models/identity/index.d.ts b/apps/mobile-app/utils/dist/core/models/identity/index.d.ts
index 6c9e9ff3e..adfdd8307 100644
--- a/apps/mobile-app/utils/dist/core/models/identity/index.d.ts
+++ b/apps/mobile-app/utils/dist/core/models/identity/index.d.ts
@@ -10,7 +10,6 @@ declare enum Gender {
/**
* A generated identity as returned by the Rust core identity generator
- * (JSON with camelCase fields).
*/
type Identity = {
firstName: string;
diff --git a/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts b/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
index a5d0edf85..e278ffb66 100644
--- a/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
+++ b/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
@@ -443,15 +443,15 @@ type MobileLoginPollResponse = {
};
/**
- * Vault key response type (KEK/VEK model). Returned by GET /v2/VaultKey/{keyType}.
- * Carries the wrapped VEK plus the KEK derivation parameters so an authenticated client can derive the KEK from
+ * Vault key response type (KEK/VEK model). Returned by GET /v2/VaultKey/{type}.
+ * Carries the encrypted VEK plus the KEK derivation parameters so an authenticated client can derive the KEK from
* the unlock secret and unwrap the vault encryption key. The SRP verifier is never returned.
*/
type VaultKeyResponse = {
/** The unlock method type, e.g. "password". */
- keyType: string;
- /** The wrapped VEK: base64(IV ‖ ciphertext ‖ authTag) of the VEK encrypted with the KEK (AES-256-GCM). */
- wrappedVek: string;
+ type: string;
+ /** The encrypted VEK: base64(IV ‖ ciphertext ‖ authTag) of the VEK encrypted with the KEK (AES-256-GCM). */
+ encryptedVek: string;
/** The salt used for KEK derivation (same value as the SRP salt for the password key type). */
salt: string;
/** The key derivation type, e.g. "Argon2Id". */
@@ -460,10 +460,10 @@ type VaultKeyResponse = {
encryptionSettings: string;
};
/**
- * Envelope returned by GET /v2/VaultKey/{keyType} with HTTP 200. A null vaultKey means the user has no vault key
+ * Envelope returned by GET /v2/VaultKey/{type} with HTTP 200. A null vaultKey means the user has no vault key
* of the requested type (legacy user). An HTTP 404 on the endpoint itself means the server does not implement
* vault keys at all (older server version) and must be treated differently: fall back to any locally cached
- * wrapped VEK instead of assuming a legacy account.
+ * encrypted VEK instead of assuming a legacy account.
*/
type VaultKeyGetResponse = {
vaultKey: VaultKeyResponse | null;
diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs
index 749c0e59a..382d14007 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs
@@ -28,7 +28,7 @@ public class VaultKeyController(IAliasServerDbContextFactory dbContextFactory, U
/// Get the wrapped VEK and KEK derivation parameters for the given key type. Always returns HTTP 200;
/// the payload's VaultKey is null when the user has no such vault key (legacy user, or unknown key type).
/// </summary>
- /// <param name="keyType">The unlock method type, e.g. "password".</param>
+ /// <param name="keyType">The unlock method type, e.g. "password" — the <see cref="VaultKeyType"/> member name, case-insensitive.</param>
/// <returns>The vault key envelope DTO.</returns>
[HttpGet("{keyType}")]
public async Task<IActionResult> Get(string keyType)
@@ -40,21 +40,32 @@ public class VaultKeyController(IAliasServerDbContextFactory dbContextFactory, U
return Unauthorized();
}
- var vaultKey = await context.VaultKeys.FirstOrDefaultAsync(x => x.UserId == user.Id && x.KeyType == keyType);
+ // A method this build does not know about is "no such key" rather than an error, so a newer client asking
+ // for one it supports and this server does not degrades to the same path as a legacy user with no key.
+ if (!Enum.TryParse<VaultKeyType>(keyType, true, out var parsedKeyType) || !Enum.IsDefined(parsedKeyType))
+ {
+ return Ok(new VaultKeyGetResponse { VaultKey = null });
+ }
+
+ var vaultKey = await context.VaultKeys.FirstOrDefaultAsync(x => x.UserId == user.Id && x.KeyType == parsedKeyType);
if (vaultKey == null)
{
return Ok(new VaultKeyGetResponse { VaultKey = null });
}
+ // The verifier stays server-side; only the KEK derivation inputs are served.
+ var (salt, _, encryptionType, encryptionSettings) = VaultKeyMetadata.Parse(vaultKey.Metadata).RequireSrpCredentials();
+
return Ok(new VaultKeyGetResponse
{
VaultKey = new VaultKeyResponse
{
- KeyType = vaultKey.KeyType,
+ // The wire contract is the lowercased member name; clients match on the literal "password".
+ KeyType = vaultKey.KeyType.ToString().ToLowerInvariant(),
WrappedVek = vaultKey.WrappedVek,
- Salt = vaultKey.Salt!,
- EncryptionType = vaultKey.EncryptionType!,
- EncryptionSettings = vaultKey.EncryptionSettings!,
+ Salt = salt,
+ EncryptionType = encryptionType,
+ EncryptionSettings = encryptionSettings,
},
});
}
diff --git a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs
index 2e0bd4987..2a11f5b06 100644
--- a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs
+++ b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs
@@ -191,8 +191,8 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon
public DbSet<RateLimit> RateLimits { get; set; }
/// <summary>
- /// Gets or sets the VaultKeys DbSet. These hold the wrapped vault encryption key (VEK) plus SRP credentials
- /// per user per unlock method (KEK/VEK model). Users without rows here are on the legacy single-derived-key model.
+ /// Gets or sets the VaultKeys DbSet. These hold the encrypted vault encryption key (VEK) and metadata
+ /// per user per unlock method (KEK/VEK model).
/// </summary>
public DbSet<VaultKey> VaultKeys { get; set; }
@@ -353,7 +353,7 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon
.OnDelete(DeleteBehavior.Cascade);
});
- // Configure VaultKey: a wrapped-VEK grant for (holder, manifest, unlock method).
+ // Configure VaultKey: an encrypted-VEK grant for (holder, manifest, unlock method).
modelBuilder.Entity<VaultKey>(builder =>
{
builder.HasOne(e => e.User)
@@ -361,9 +361,14 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon
.HasForeignKey(e => e.UserId)
.OnDelete(DeleteBehavior.Cascade);
- builder.HasIndex(e => new { e.UserId, e.KeyType, e.VaultManifestId }).IsUnique().HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");
+ builder.HasIndex(e => new { e.UserId, e.Type, e.VaultManifestId }).IsUnique().HasDatabaseName("UX_VaultKeys_UserId_Type_Manifest");
builder.HasIndex(e => e.VaultManifestId).HasDatabaseName("IX_VaultKeys_VaultManifestId");
builder.Property(e => e.Metadata).HasColumnType("jsonb");
+ builder.Property(e => e.Algorithm).HasConversion(v => VaultKeyAlgorithms.ToToken(v), v => VaultKeyAlgorithms.Parse(v));
+ builder.HasOne(e => e.EncryptionKey)
+ .WithMany()
+ .HasForeignKey(e => e.EncryptionKeyId)
+ .OnDelete(DeleteBehavior.SetNull);
});
/*
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.Designer.cs
index bb0e334e8..b2aa73870 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.Designer.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.Designer.cs
@@ -932,16 +932,11 @@ namespace AliasServerDb.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
- b.Property<string>("EncryptionSettings")
- .HasColumnType("text");
-
- b.Property<string>("EncryptionType")
- .HasColumnType("text");
+ b.Property<Guid?>("EncryptionKeyId")
+ .HasColumnType("uuid");
- b.Property<string>("KeyType")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
+ b.Property<int>("Type")
+ .HasColumnType("integer");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
@@ -949,13 +944,6 @@ namespace AliasServerDb.Migrations
b.Property<string>("Metadata")
.HasColumnType("jsonb");
- b.Property<Guid?>("RecipientPublicKeyId")
- .HasColumnType("uuid");
-
- b.Property<string>("Salt")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
@@ -964,30 +952,28 @@ namespace AliasServerDb.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
- b.Property<Guid?>("VaultManifestId")
+ b.Property<Guid>("VaultManifestId")
.HasColumnType("uuid");
- b.Property<string>("Verifier")
- .HasMaxLength(1000)
- .HasColumnType("character varying(1000)");
-
- b.Property<string>("WrapScheme")
+ b.Property<string>("Algorithm")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
- b.Property<string>("WrappedVek")
+ b.Property<string>("EncryptedVek")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
+ b.HasIndex("EncryptionKeyId");
+
b.HasIndex("VaultManifestId")
.HasDatabaseName("IX_VaultKeys_VaultManifestId");
- b.HasIndex("UserId", "KeyType", "VaultManifestId")
+ b.HasIndex("UserId", "Type", "VaultManifestId")
.IsUnique()
- .HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");
+ .HasDatabaseName("UX_VaultKeys_UserId_Type_Manifest");
b.ToTable("VaultKeys");
});
@@ -1438,12 +1424,19 @@ namespace AliasServerDb.Migrations
modelBuilder.Entity("AliasServerDb.VaultKey", b =>
{
+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey")
+ .WithMany()
+ .HasForeignKey("EncryptionKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany("VaultKeys")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.Navigation("EncryptionKey");
+
b.Navigation("User");
});
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.cs b/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.cs
index 8f4e6c408..d20c30aef 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260726192459_AddManifestStorage.cs
@@ -207,15 +207,11 @@ namespace AliasServerDb.Migrations
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
- VaultManifestId = table.Column<Guid>(type: "uuid", nullable: true),
- KeyType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
- WrapScheme = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
- WrappedVek = table.Column<string>(type: "text", nullable: false),
- Salt = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
- Verifier = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
- EncryptionType = table.Column<string>(type: "text", nullable: true),
- EncryptionSettings = table.Column<string>(type: "text", nullable: true),
- RecipientPublicKeyId = table.Column<Guid>(type: "uuid", nullable: true),
+ VaultManifestId = table.Column<Guid>(type: "uuid", nullable: false),
+ Type = table.Column<int>(type: "integer", nullable: false),
+ Algorithm = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
+ EncryptedVek = table.Column<string>(type: "text", nullable: false),
+ EncryptionKeyId = table.Column<Guid>(type: "uuid", nullable: true),
Metadata = table.Column<string>(type: "jsonb", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
@@ -230,6 +226,12 @@ namespace AliasServerDb.Migrations
principalTable: "AliasVaultUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_VaultKeys_UserEncryptionKeys_EncryptionKeyId",
+ column: x => x.EncryptionKeyId,
+ principalTable: "UserEncryptionKeys",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
@@ -262,9 +264,14 @@ namespace AliasServerDb.Migrations
column: "VaultManifestId");
migrationBuilder.CreateIndex(
- name: "UX_VaultKeys_UserId_KeyType_Manifest",
+ name: "IX_VaultKeys_EncryptionKeyId",
+ table: "VaultKeys",
+ column: "EncryptionKeyId");
+
+ migrationBuilder.CreateIndex(
+ name: "UX_VaultKeys_UserId_Type_Manifest",
table: "VaultKeys",
- columns: new[] { "UserId", "KeyType", "VaultManifestId" },
+ columns: new[] { "UserId", "Type", "VaultManifestId" },
unique: true);
// --- 7. Email encryption keys become per-manifest, and claims record which key they were issued under. ---
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.Designer.cs
index af48cd4cc..3408ded5e 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.Designer.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.Designer.cs
@@ -1000,16 +1000,11 @@ namespace AliasServerDb.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
- b.Property<string>("EncryptionSettings")
- .HasColumnType("text");
-
- b.Property<string>("EncryptionType")
- .HasColumnType("text");
+ b.Property<Guid?>("EncryptionKeyId")
+ .HasColumnType("uuid");
- b.Property<string>("KeyType")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
+ b.Property<int>("Type")
+ .HasColumnType("integer");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
@@ -1017,13 +1012,6 @@ namespace AliasServerDb.Migrations
b.Property<string>("Metadata")
.HasColumnType("jsonb");
- b.Property<Guid?>("RecipientPublicKeyId")
- .HasColumnType("uuid");
-
- b.Property<string>("Salt")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
@@ -1032,30 +1020,28 @@ namespace AliasServerDb.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
- b.Property<Guid?>("VaultManifestId")
+ b.Property<Guid>("VaultManifestId")
.HasColumnType("uuid");
- b.Property<string>("Verifier")
- .HasMaxLength(1000)
- .HasColumnType("character varying(1000)");
-
- b.Property<string>("WrapScheme")
+ b.Property<string>("Algorithm")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
- b.Property<string>("WrappedVek")
+ b.Property<string>("EncryptedVek")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
+ b.HasIndex("EncryptionKeyId");
+
b.HasIndex("VaultManifestId")
.HasDatabaseName("IX_VaultKeys_VaultManifestId");
- b.HasIndex("UserId", "KeyType", "VaultManifestId")
+ b.HasIndex("UserId", "Type", "VaultManifestId")
.IsUnique()
- .HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");
+ .HasDatabaseName("UX_VaultKeys_UserId_Type_Manifest");
b.ToTable("VaultKeys");
});
@@ -1533,12 +1519,19 @@ namespace AliasServerDb.Migrations
modelBuilder.Entity("AliasServerDb.VaultKey", b =>
{
+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey")
+ .WithMany()
+ .HasForeignKey("EncryptionKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany("VaultKeys")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.Navigation("EncryptionKey");
+
b.Navigation("User");
});
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.cs b/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.cs
index d4e474586..0a20f78c0 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260728102956_AddGroupsAndSharedOwnership.cs
@@ -33,6 +33,7 @@ namespace AliasServerDb.Migrations
migrationBuilder.Sql("""
ALTER TABLE "EmailClaims" RENAME CONSTRAINT "PK_UserEmailClaims" TO "PK_EmailClaims";
ALTER TABLE "EncryptionKeys" RENAME CONSTRAINT "PK_UserEncryptionKeys" TO "PK_EncryptionKeys";
+ ALTER TABLE "VaultKeys" RENAME CONSTRAINT "FK_VaultKeys_UserEncryptionKeys_EncryptionKeyId" TO "FK_VaultKeys_EncryptionKeys_EncryptionKeyId";
""");
migrationBuilder.RenameIndex(name: "IX_UserEmailClaims_Address", table: "EmailClaims", newName: "IX_EmailClaims_Address");
migrationBuilder.RenameIndex(name: "IX_UserEmailClaims_EncryptionKeyId", table: "EmailClaims", newName: "IX_EmailClaims_EncryptionKeyId");
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.cs
index b64008739..c242aa649 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.cs
@@ -995,16 +995,11 @@ namespace AliasServerDb.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
- b.Property<string>("EncryptionSettings")
- .HasColumnType("text");
-
- b.Property<string>("EncryptionType")
- .HasColumnType("text");
+ b.Property<Guid?>("EncryptionKeyId")
+ .HasColumnType("uuid");
- b.Property<string>("KeyType")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
+ b.Property<int>("Type")
+ .HasColumnType("integer");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
@@ -1012,13 +1007,6 @@ namespace AliasServerDb.Migrations
b.Property<string>("Metadata")
.HasColumnType("jsonb");
- b.Property<Guid?>("RecipientPublicKeyId")
- .HasColumnType("uuid");
-
- b.Property<string>("Salt")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
@@ -1027,30 +1015,28 @@ namespace AliasServerDb.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
- b.Property<Guid?>("VaultManifestId")
+ b.Property<Guid>("VaultManifestId")
.HasColumnType("uuid");
- b.Property<string>("Verifier")
- .HasMaxLength(1000)
- .HasColumnType("character varying(1000)");
-
- b.Property<string>("WrapScheme")
+ b.Property<string>("Algorithm")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
- b.Property<string>("WrappedVek")
+ b.Property<string>("EncryptedVek")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
+ b.HasIndex("EncryptionKeyId");
+
b.HasIndex("VaultManifestId")
.HasDatabaseName("IX_VaultKeys_VaultManifestId");
- b.HasIndex("UserId", "KeyType", "VaultManifestId")
+ b.HasIndex("UserId", "Type", "VaultManifestId")
.IsUnique()
- .HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");
+ .HasDatabaseName("UX_VaultKeys_UserId_Type_Manifest");
b.ToTable("VaultKeys");
});
@@ -1521,12 +1507,19 @@ namespace AliasServerDb.Migrations
modelBuilder.Entity("AliasServerDb.VaultKey", b =>
{
+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey")
+ .WithMany()
+ .HasForeignKey("EncryptionKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany("VaultKeys")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.Navigation("EncryptionKey");
+
b.Navigation("User");
});
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.cs b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.cs
index dc9effae3..72a21f7a0 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.cs
@@ -67,9 +67,6 @@ namespace AliasServerDb.Migrations
type: "uuid",
nullable: true);
- // Repopulate the owning group from each claim's manifest, then restore the previous convention in
- // which a personal alias carried no manifest at all — otherwise the reverted code would read every
- // personal claim as if it lived in a shared folder.
migrationBuilder.Sql(@"
UPDATE ""EmailClaims"" c
SET ""OwnerGroupId"" = m.""OwnerGroupId""
diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
index bce5efe34..8aaa382b8 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
@@ -992,16 +992,11 @@ namespace AliasServerDb.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
- b.Property<string>("EncryptionSettings")
- .HasColumnType("text");
-
- b.Property<string>("EncryptionType")
- .HasColumnType("text");
+ b.Property<Guid?>("EncryptionKeyId")
+ .HasColumnType("uuid");
- b.Property<string>("KeyType")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
+ b.Property<int>("Type")
+ .HasColumnType("integer");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
@@ -1009,13 +1004,6 @@ namespace AliasServerDb.Migrations
b.Property<string>("Metadata")
.HasColumnType("jsonb");
- b.Property<Guid?>("RecipientPublicKeyId")
- .HasColumnType("uuid");
-
- b.Property<string>("Salt")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
@@ -1024,30 +1012,28 @@ namespace AliasServerDb.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
- b.Property<Guid?>("VaultManifestId")
+ b.Property<Guid>("VaultManifestId")
.HasColumnType("uuid");
- b.Property<string>("Verifier")
- .HasMaxLength(1000)
- .HasColumnType("character varying(1000)");
-
- b.Property<string>("WrapScheme")
+ b.Property<string>("Algorithm")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
- b.Property<string>("WrappedVek")
+ b.Property<string>("EncryptedVek")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
+ b.HasIndex("EncryptionKeyId");
+
b.HasIndex("VaultManifestId")
.HasDatabaseName("IX_VaultKeys_VaultManifestId");
- b.HasIndex("UserId", "KeyType", "VaultManifestId")
+ b.HasIndex("UserId", "Type", "VaultManifestId")
.IsUnique()
- .HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");
+ .HasDatabaseName("UX_VaultKeys_UserId_Type_Manifest");
b.ToTable("VaultKeys");
});
@@ -1518,12 +1504,19 @@ namespace AliasServerDb.Migrations
modelBuilder.Entity("AliasServerDb.VaultKey", b =>
{
+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey")
+ .WithMany()
+ .HasForeignKey("EncryptionKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany("VaultKeys")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.Navigation("EncryptionKey");
+
b.Navigation("User");
});
diff --git a/apps/server/Databases/AliasServerDb/VaultKey.cs b/apps/server/Databases/AliasServerDb/VaultKey.cs
index 6d2376681..c717ff05f 100644
--- a/apps/server/Databases/AliasServerDb/VaultKey.cs
+++ b/apps/server/Databases/AliasServerDb/VaultKey.cs
@@ -10,10 +10,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
-/// A vault unlock key for a user (KEK/VEK model). The vault content is encrypted with a random Vault Encryption Key
-/// (VEK) that never changes; this entity stores that VEK wrapped (AES-GCM encrypted) with a Key Encryption Key (KEK)
-/// derived from an unlock method. One row per user per unlock method. Users without any VaultKey rows are on the legacy
-/// model where the SRP credentials live on the root vault manifest and the password-derived key encrypts the vault directly.
+/// A key unlock key (KEK) for a user, used to encrypt/decrypt the vault encryption key (VEK) which then encrypts/decrypts the vault content.
/// </summary>
public class VaultKey
{
@@ -36,60 +33,41 @@ public class VaultKey
public virtual AliasVaultUser User { get; set; } = null!;
/// <summary>
- /// Gets or sets the manifest this key unlocks. Null means the user's main (root) vault.
+ /// Gets or sets the manifest this key unlocks.
/// </summary>
- public Guid? VaultManifestId { get; set; }
+ public required Guid VaultManifestId { get; set; }
/// <summary>
- /// Gets or sets the unlock method type: "password" (R1). Extensible for R2+: "webauthn", "recovery", "shared".
+ /// Gets or sets the unlock method this key represents, i.e. what its holder proves to obtain the KEK.
/// </summary>
- [StringLength(50)]
- public required string KeyType { get; set; }
+ public required VaultKeyType Type { get; set; }
/// <summary>
- /// Gets or sets which wrap scheme was used to encrypt the wrapped VEK.
+ /// Gets or sets the algorithm <see cref="EncryptedVek"/> is encrypted with.
/// </summary>
[StringLength(30)]
- public required string WrapScheme { get; set; }
+ public required VaultKeyAlgorithm Algorithm { get; set; }
/// <summary>
- /// Gets or sets the wrapped VEK: base64(IV | ciphertext | authTag) of the VEK encrypted with the KEK (AES-256-GCM).
+ /// Gets or sets the encrypted VEK (which is encrypted with this KEK record).
/// </summary>
- public required string WrappedVek { get; set; }
+ public required string EncryptedVek { get; set; }
/// <summary>
- /// Gets or sets the salt used both for KEK derivation and SRP authentication. Set for SRP-authenticating self
- /// methods (password); null for methods that don't authenticate via SRP (webauthn, recovery) or shared keys.
+ /// Gets or sets the navigation property to the encryption key that encrypted the VEK. This value is only set for
+ /// shared vault keys (Type = <see cref="VaultKeyType.PublicKey"/>) which means a registered user's public key is used for encryption.
/// </summary>
- [StringLength(100)]
- public string? Salt { get; set; }
+ public Guid? EncryptionKeyId { get; set; }
/// <summary>
- /// Gets or sets the verifier used for SRP authentication. Null for non-SRP key types (see <see cref="Salt"/>).
+ /// Gets or sets the navigation property to the encryption key that encrypted the VEK. This value is only set for
+ /// shared vault keys (Type = <see cref="VaultKeyType.PublicKey"/>) which means a registered user's public key is used for encryption.
/// </summary>
- [StringLength(1000)]
- public string? Verifier { get; set; }
+ public virtual EncryptionKey? EncryptionKey { get; set; }
/// <summary>
- /// Gets or sets the encryption (key derivation) type. Null for non-SRP key types (see <see cref="Salt"/>).
- /// </summary>
- public string? EncryptionType { get; set; }
-
- /// <summary>
- /// Gets or sets the encryption (key derivation) settings. Null for non-SRP key types (see <see cref="Salt"/>).
- /// </summary>
- public string? EncryptionSettings { get; set; }
-
- /// <summary>
- /// Gets or sets, for a shared (asymmetric) key, the foreign key to the recipient <see cref="UserEncryptionKey"/>
- /// whose public key wrapped this VEK.
- /// </summary>
- public Guid? RecipientPublicKeyId { get; set; }
-
- /// <summary>
- /// Gets or sets an optional per-key-type extension bag (JSON) for fields the server never evaluates, e.g. a
- /// WebAuthn credential id + transports + PRF salt, or recovery-code derivation params. A new unlock method can
- /// add fields here with no schema migration. Null when the key type needs no extra fields.
+ /// Gets or sets optional per-key-type fields as JSON, e.g. SRP salt and verifier, KDF parameters etc. Read and written
+ /// through <see cref="VaultKeyMetadata"/>.
/// </summary>
public string? Metadata { get; set; }
diff --git a/apps/server/Databases/AliasServerDb/VaultKeyAlgorithm.cs b/apps/server/Databases/AliasServerDb/VaultKeyAlgorithm.cs
new file mode 100644
index 000000000..463c787ab
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/VaultKeyAlgorithm.cs
@@ -0,0 +1,24 @@
+//-----------------------------------------------------------------------
+// <copyright file="VaultKeyAlgorithm.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasServerDb;
+
+/// <summary>
+/// Algorithms a VEK can be encrypted with.
+/// </summary>
+public enum VaultKeyAlgorithm
+{
+ /// <summary>
+ /// AES-256-GCM with a 96-bit IV and 128-bit tag.
+ /// </summary>
+ Aes256Gcm = 0,
+
+ /// <summary>
+ /// RSA-OAEP with a 2048-bit modulus, SHA-256 and MGF1-SHA-256.
+ /// </summary>
+ RsaOaepSha256 = 1,
+}
diff --git a/apps/server/Databases/AliasServerDb/VaultKeyAlgorithms.cs b/apps/server/Databases/AliasServerDb/VaultKeyAlgorithms.cs
new file mode 100644
index 000000000..8551029da
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/VaultKeyAlgorithms.cs
@@ -0,0 +1,81 @@
+//-----------------------------------------------------------------------
+// <copyright file="VaultKeyAlgorithms.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasServerDb;
+
+/// <summary>
+/// Vault key encryption algorithms.
+/// </summary>
+public static class VaultKeyAlgorithms
+{
+ /// <summary>
+ /// The token for <see cref="VaultKeyAlgorithm.Aes256Gcm"/>.
+ /// </summary>
+ public const string Aes256GcmToken = "aes256-gcm";
+
+ /// <summary>
+ /// The token for <see cref="VaultKeyAlgorithm.RsaOaepSha256"/>.
+ /// </summary>
+ public const string RsaOaepSha256Token = "rsa-oaep-sha256";
+
+ /// <summary>
+ /// Returns the token for an algorithm.
+ /// </summary>
+ /// <param name="algorithm">The algorithm to convert.</param>
+ /// <returns>The token.</returns>
+ public static string ToToken(VaultKeyAlgorithm algorithm) => algorithm switch
+ {
+ VaultKeyAlgorithm.Aes256Gcm => Aes256GcmToken,
+ VaultKeyAlgorithm.RsaOaepSha256 => RsaOaepSha256Token,
+ _ => throw new ArgumentOutOfRangeException(nameof(algorithm), algorithm, "Unknown vault key algorithm."),
+ };
+
+ /// <summary>
+ /// Parses a token.
+ /// </summary>
+ /// <param name="token">The token to parse.</param>
+ /// <param name="algorithm">The parsed algorithm.</param>
+ /// <returns>True when the token names an algorithm this build supports.</returns>
+ public static bool TryParse(string? token, out VaultKeyAlgorithm algorithm)
+ {
+ switch (token)
+ {
+ case Aes256GcmToken:
+ algorithm = VaultKeyAlgorithm.Aes256Gcm;
+ return true;
+ case RsaOaepSha256Token:
+ algorithm = VaultKeyAlgorithm.RsaOaepSha256;
+ return true;
+ default:
+ algorithm = default;
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Parses a token and returns the algorithm.
+ /// </summary>
+ /// <param name="token">The token to parse.</param>
+ /// <returns>The parsed algorithm.</returns>
+ public static VaultKeyAlgorithm Parse(string? token)
+ {
+ if (!TryParse(token, out var algorithm))
+ {
+ throw new ArgumentOutOfRangeException(nameof(token), token, "Unknown vault key algorithm token.");
+ }
+
+ return algorithm;
+ }
+
+ /// <summary>
+ /// Whether an algorithm encrypts to a public key, i.e. is valid on a <see cref="VaultKeyType.PublicKey"/> grant. A
+ /// symmetric algorithm there would mean the sharer and the recipient share a secret, which they never do.
+ /// </summary>
+ /// <param name="algorithm">The algorithm to check.</param>
+ /// <returns>True for asymmetric algorithms.</returns>
+ public static bool IsAsymmetric(VaultKeyAlgorithm algorithm) => algorithm == VaultKeyAlgorithm.RsaOaepSha256;
+}
diff --git a/apps/server/Databases/AliasServerDb/VaultKeyMetadata.cs b/apps/server/Databases/AliasServerDb/VaultKeyMetadata.cs
new file mode 100644
index 000000000..27e042f1b
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/VaultKeyMetadata.cs
@@ -0,0 +1,87 @@
+//-----------------------------------------------------------------------
+// <copyright file="VaultKeyMetadata.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasServerDb;
+
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+/// <summary>
+/// The per-method specific fields of a <see cref="VaultKey"/> stored in a JSON column.
+/// </summary>
+public sealed class VaultKeyMetadata
+{
+ /// <summary>
+ /// Serializer settings for the column.
+ /// </summary>
+ private static readonly JsonSerializerOptions SerializerOptions = new()
+ {
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
+ };
+
+ /// <summary>
+ /// Gets or sets the salt.
+ /// </summary>
+ public string? Salt { get; set; }
+
+ /// <summary>
+ /// Gets or sets the verifier used for SRP authentication.
+ /// </summary>
+ public string? SrpVerifier { get; set; }
+
+ /// <summary>
+ /// Gets or sets the KDF the client derives the KEK with, e.g. <c>Argon2Id</c>.
+ /// </summary>
+ public string? EncryptionType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the encryption settings belonging to <see cref="EncryptionType"/>.
+ /// </summary>
+ public string? EncryptionSettings { get; set; }
+
+ /// <summary>
+ /// Gets or sets the additional fields that are not defined as explicit properties.
+ /// </summary>
+ [JsonExtensionData]
+ public Dictionary<string, JsonElement>? AdditionalFields { get; set; }
+
+ /// <summary>
+ /// Parses the JSON column value.
+ /// </summary>
+ /// <param name="json">The raw column value.</param>
+ /// <returns>The parsed metadata.</returns>
+ public static VaultKeyMetadata Parse(string? json)
+ {
+ if (string.IsNullOrWhiteSpace(json))
+ {
+ return new VaultKeyMetadata();
+ }
+
+ return JsonSerializer.Deserialize<VaultKeyMetadata>(json, SerializerOptions) ?? new VaultKeyMetadata();
+ }
+
+ /// <summary>
+ /// Serializes this metadata for storage in the column.
+ /// </summary>
+ /// <returns>The JSON document to store.</returns>
+ public string ToJson() => JsonSerializer.Serialize(this, SerializerOptions);
+
+ /// <summary>
+ /// Helper method to return the SRP credentials and KDF parameters.
+ /// </summary>
+ /// <returns>Tuple with salt, verifier, encryption type and encryption settings.</returns>
+ public (string Salt, string SrpVerifier, string EncryptionType, string EncryptionSettings) RequireSrpCredentials()
+ {
+ if (Salt is null || SrpVerifier is null || EncryptionType is null || EncryptionSettings is null)
+ {
+ throw new InvalidOperationException("Vault key metadata is missing SRP credentials.");
+ }
+
+ return (Salt, SrpVerifier, EncryptionType, EncryptionSettings);
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/VaultKeyType.cs b/apps/server/Databases/AliasServerDb/VaultKeyType.cs
new file mode 100644
index 000000000..e1b1f97b7
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/VaultKeyType.cs
@@ -0,0 +1,24 @@
+//-----------------------------------------------------------------------
+// <copyright file="VaultKeyType.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasServerDb;
+
+/// <summary>
+/// Vault key types.
+/// </summary>
+public enum VaultKeyType
+{
+ /// <summary>
+ /// Master password.
+ /// </summary>
+ Password = 0,
+
+ /// <summary>
+ /// Public key encryption, uses a registered user's public key (see <see cref="EncryptionKey"/>).
+ /// </summary>
+ PublicKey = 1,
+}
diff --git a/apps/server/Databases/AliasServerDb/VaultManifest.cs b/apps/server/Databases/AliasServerDb/VaultManifest.cs
index 293caf458..101f49df8 100644
--- a/apps/server/Databases/AliasServerDb/VaultManifest.cs
+++ b/apps/server/Databases/AliasServerDb/VaultManifest.cs
@@ -24,30 +24,24 @@ public class VaultManifest : VaultManifestBase
public Guid ManifestId { get; set; }
/// <summary>
- /// Gets or sets a value indicating whether this manifest is the user's root manifest: the residual container that
- /// holds everything not carved out into another manifest. Every user has exactly one root manifest (enforced by a
- /// partial unique index). Note: this describes the manifest's role in client-side vault composition only — access
- /// and sharing are tracked separately (R2 access table); a non-root manifest is not necessarily shared.
+ /// Gets or sets a value indicating whether this manifest is the user's root manifest.
/// </summary>
public required bool IsRoot { get; set; }
/// <summary>
- /// Gets or sets the display name of a shared folder manifest. Null for the root manifest (the user's main vault
- /// has no name). Set only for non-root manifests, which — by definition — are shareable folders. This is stored
- /// in plaintext so the sharing/ACL UI can list folders and pending shares without decrypting their content.
+ /// Gets or sets the optional display name of a manifest. Used in e.g. sharing UI.
/// </summary>
[StringLength(255)]
public string? Name { get; set; }
/// <summary>
- /// Gets or sets the ID of the owning user.
+ /// Gets or sets the group that owns this manifest.
/// </summary>
- [StringLength(255)]
- public string OwnerUserId { get; set; } = null!;
+ public Guid OwnerGroupId { get; set; }
/// <summary>
- /// Gets or sets foreign key to the AliasVaultUser object.
+ /// Gets or sets the navigation property to the owning group.
/// </summary>
- [ForeignKey("OwnerUserId")]
- public virtual AliasVaultUser User { get; set; } = null!;
+ [ForeignKey("OwnerGroupId")]
+ public virtual Group OwnerGroup { get; set; } = null!;
}
diff --git a/apps/server/Databases/AliasServerDb/VaultManifestsHistory.cs b/apps/server/Databases/AliasServerDb/VaultManifestsHistory.cs
index 17a691334..371ac8339 100644
--- a/apps/server/Databases/AliasServerDb/VaultManifestsHistory.cs
+++ b/apps/server/Databases/AliasServerDb/VaultManifestsHistory.cs
@@ -6,7 +6,6 @@
//-----------------------------------------------------------------------
namespace AliasServerDb;
-using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
@@ -28,13 +27,6 @@ public class VaultManifestsHistory : VaultManifestBase
[ForeignKey("ManifestId")]
public virtual VaultManifest Manifest { get; set; } = null!;
- /// <summary>
- /// Gets or sets the ID of the owning user. Denormalized from <see cref="VaultManifest.OwnerUserId"/> for direct
- /// per-user queries; intentionally has no FK of its own — history rows cascade via the ManifestId FK.
- /// </summary>
- [StringLength(255)]
- public string OwnerUserId { get; set; } = null!;
-
/// <summary>
/// Creates a history row from the current revision of a manifest. Called right before the current row is updated
/// in place with a newer revision.
@@ -46,7 +38,6 @@ public class VaultManifestsHistory : VaultManifestBase
var history = new VaultManifestsHistory
{
ManifestId = current.ManifestId,
- OwnerUserId = current.OwnerUserId,
VaultBlob = current.VaultBlob,
StorageFormat = current.StorageFormat,
Version = current.Version,
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs
index b70739e51..bd48851f3 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs
@@ -29,6 +29,6 @@ public class CreateSharedFolderRequest
/// <summary>Gets or sets the id of the caller's own public key used to wrap (from GET /v2/Sharing/recipient for their own username).</summary>
public required Guid SelfPublicKeyId { get; set; }
- /// <summary>Gets or sets the asymmetric wrap scheme used, e.g. "rsa-oaep".</summary>
+ /// <summary>Gets or sets the asymmetric wrap scheme used, e.g. "rsa-oaep-sha256". See AliasServerDb.VaultKeyWrapScheme for the supported tokens.</summary>
public required string WrapScheme { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs
index 0fb341a42..99d01acb6 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs
@@ -25,6 +25,6 @@ public class GrantAccessRequest
/// <summary>Gets or sets the id of the recipient public key used to wrap (from GET /v2/Sharing/recipient).</summary>
public required Guid RecipientPublicKeyId { get; set; }
- /// <summary>Gets or sets the asymmetric wrap scheme used, e.g. "rsa-oaep" or "x25519-sealedbox".</summary>
+ /// <summary>Gets or sets the asymmetric wrap scheme used, e.g. "rsa-oaep-sha256". See AliasServerDb.VaultKeyWrapScheme for the supported tokens.</summary>
public required string WrapScheme { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
index cf873c298..1c5ba1c35 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
@@ -49,7 +49,7 @@ public class Manifest
/// </summary>
public string? WrappedVek { get; set; }
- /// <summary>Gets or sets the wrap scheme of <see cref="WrappedVek"/> (e.g. "rsa-oaep"). Null when <see cref="WrappedVek"/> is null.</summary>
+ /// <summary>Gets or sets the wrap scheme of <see cref="WrappedVek"/> (e.g. "rsa-oaep-sha256"). Null when <see cref="WrappedVek"/> is null.</summary>
public string? WrapScheme { get; set; }
/// <summary>