Skip to content

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

Update vault sharing API models (#2159)

Leendert de Borste00714f59986
diff --git a/apps/server/Databases/AliasServerDb/ClientAction.cs b/apps/server/Databases/AliasServerDb/ClientAction.cs
new file mode 100644
index 000000000..0649858ad
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/ClientAction.cs
@@ -0,0 +1,77 @@
+//-----------------------------------------------------------------------
+// <copyright file="ClientAction.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.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using Microsoft.EntityFrameworkCore;
+
+/// <summary>
+/// A piece of work the server needs a client to carry out, because something happened outside that client's own
+/// context and only a client can finish it: anything requiring vault content, a vault key or a private key is the
+/// server's to notice and the client's to do.
+/// </summary>
+[Index(nameof(TargetUserId))]
+[Index(nameof(TargetGroupId))]
+public class ClientAction
+{
+ /// <summary>
+ /// Gets or sets the primary key, which is also the handle a client completes the action by.
+ /// </summary>
+ [Key]
+ public Guid Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets what has to be done.
+ /// </summary>
+ [StringLength(50)]
+ public required ClientActionType Type { get; set; }
+
+ /// <summary>
+ /// Gets or sets the single account that must carry the action out (optional).
+ /// </summary>
+ [StringLength(255)]
+ public string? TargetUserId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the navigation property to the targeted account.
+ /// </summary>
+ [ForeignKey("TargetUserId")]
+ public virtual AliasVaultUser? TargetUser { get; set; }
+
+ /// <summary>
+ /// Gets or sets the group whose admins must carry the action out (optional).
+ /// </summary>
+ public Guid? TargetGroupId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the navigation property to the targeted group.
+ /// </summary>
+ [ForeignKey("TargetGroupId")]
+ public virtual Group? TargetGroup { get; set; }
+
+ /// <summary>
+ /// Gets or sets the manifest the action is about (optional).
+ /// </summary>
+ public Guid? ManifestId { get; set; }
+
+ /// <summary>
+ /// Gets or sets action-specific parameters as JSON, or null when the type and its subject say everything.
+ /// </summary>
+ public string? Payload { get; set; }
+
+ /// <summary>
+ /// Gets or sets created timestamp, i.e. when the server noticed the work was needed.
+ /// </summary>
+ public DateTime CreatedAt { get; set; }
+
+ /// <summary>
+ /// Gets or sets updated timestamp.
+ /// </summary>
+ public DateTime UpdatedAt { get; set; }
+}
diff --git a/apps/server/Databases/AliasServerDb/ClientActionType.cs b/apps/server/Databases/AliasServerDb/ClientActionType.cs
new file mode 100644
index 000000000..59c86f574
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/ClientActionType.cs
@@ -0,0 +1,21 @@
+//-----------------------------------------------------------------------
+// <copyright file="ClientActionType.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>
+/// The kinds of work a <see cref="ClientAction"/> can ask a client to carry out.
+/// </summary>
+public enum ClientActionType
+{
+ /// <summary>
+ /// The delivery keypair of a shared manifest has to be replaced, because a user who previously had access to
+ /// its private half was removed from the owning group. Note: this is different from access to mail, as a user that
+ /// is not part of a group anymore won't be able to fetch mail of the group's owned email aliases.
+ /// </summary>
+ RotateManifestDeliveryKey = 0,
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/ClientActions/PendingClientAction.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/ClientActions/PendingClientAction.cs
new file mode 100644
index 000000000..f06efe71e
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/ClientActions/PendingClientAction.cs
@@ -0,0 +1,27 @@
+//-----------------------------------------------------------------------
+// <copyright file="PendingClientAction.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 AliasVault.Shared.Models.WebApi.V2.ClientActions;
+
+/// <summary>
+/// A piece of generic work the server needs a client to carry out due to the E2EE model. This primarily affects vault sharing
+/// and revocation actions.
+/// </summary>
+public class PendingClientAction
+{
+ /// <summary>Gets or sets the action id, the handle it is reported done by.</summary>
+ public required Guid Id { get; set; }
+
+ /// <summary>Gets or sets what has to be done, as a token (see the server's <c>ClientActionType</c>).</summary>
+ public required string Type { get; set; }
+
+ /// <summary>Gets or sets the manifest the action is about (optional).</summary>
+ public Guid? ManifestId { get; set; }
+
+ /// <summary>Gets or sets the optional action-specific parameters as raw JSON.</summary>
+ public string? Payload { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs
index 3703c0442..b345be2ba 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs
@@ -8,17 +8,14 @@
namespace AliasVault.Shared.Models.WebApi.V2.Sharing;
/// <summary>
-/// Request for POST /v2/Sharing/manifests. Creates a new shared (non-personal) manifest owned by the caller. The
-/// manifest's VEK is generated client-side and encrypted for the caller's *own* public key, persisted as a
-/// <c>shared</c> grant in the same call.
+/// Request for POST /v2/Sharing/manifests. Creates a new shared (non-personal) manifest filed under a group.
/// </summary>
public class CreateSharedManifestRequest
{
- /// <summary>Gets or sets the client-minted id of the new manifest. The encrypted placeholder manifest
- /// already carries this id as its identity, so the server persists it verbatim (validating uniqueness).</summary>
+ /// <summary>Gets or sets the client-minted id of the new manifest.</summary>
public required Guid ManifestId { get; set; }
- /// <summary>Gets or sets the plaintext display name of the manifest (server-visible for the sharing UI).</summary>
+ /// <summary>Gets or sets the plaintext display name of the manifest.</summary>
public required string Name { get; set; }
/// <summary>
@@ -38,6 +35,10 @@ public class CreateSharedManifestRequest
/// <summary>Gets or sets the id of the caller's own account public key used to encrypt (from GET /v2/Sharing/recipient for their own username).</summary>
public required Guid SelfPublicKeyId { get; set; }
- /// <summary>Gets or sets the asymmetric algorithm used.</summary>
+ /// <summary>Gets or sets the asymmetric algorithm used, both for the caller's own grant and for <see cref="Grants"/>.</summary>
public required string Algorithm { get; set; }
+
+ /// <summary>Gets or sets the grants handed to fellow group members, applied in the same transaction as the
+ /// manifest itself (optional).</summary>
+ public List<ManifestGrant> Grants { 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
deleted file mode 100644
index 0406f6f81..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="GrantAccessRequest.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
-
-/// <summary>
-/// Request for POST /v2/Sharing/grant. Grants a recipient access to a shared manifest the caller owns, by
-/// persisting the folder's VEK encrypted with the recipient's public key. The server never sees the plaintext VEK.
-/// </summary>
-public class GrantAccessRequest
-{
- /// <summary>Gets or sets the shared manifest to grant access to (must be owned by the caller).</summary>
- public required Guid ManifestId { get; set; }
-
- /// <summary>Gets or sets the recipient user id (from GET /v2/Sharing/recipient).</summary>
- public required string RecipientUserId { get; set; }
-
- /// <summary>Gets or sets the folder VEK encrypted with the recipient's public key (base64), decryptable only by the recipient.</summary>
- public required string EncryptedVek { get; set; }
-
- /// <summary>Gets or sets the id of the recipient public key used to encrypt (from GET /v2/Sharing/recipient).</summary>
- public required Guid RecipientPublicKeyId { get; set; }
-
- /// <summary>Gets or sets the assymetric algorithm used..</summary>
- public required string Algorithm { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantRecipient.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantRecipient.cs
new file mode 100644
index 000000000..53d75e931
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantRecipient.cs
@@ -0,0 +1,23 @@
+//-----------------------------------------------------------------------
+// <copyright file="GrantRecipient.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
+
+/// <summary>
+/// A user a shared manifest's VEK can be encrypted for, with the public key to encrypt it with.
+/// </summary>
+public class GrantRecipient
+{
+ /// <summary>Gets or sets the user id.</summary>
+ public required string UserId { get; set; }
+
+ /// <summary>Gets or sets the id of the user's primary public key, echoed back on the grant.</summary>
+ public required Guid PublicKeyId { get; set; }
+
+ /// <summary>Gets or sets the public key itself (JWK).</summary>
+ public required string PublicKey { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ManifestGrant.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ManifestGrant.cs
new file mode 100644
index 000000000..859c76fa4
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ManifestGrant.cs
@@ -0,0 +1,23 @@
+//-----------------------------------------------------------------------
+// <copyright file="ManifestGrant.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
+
+/// <summary>
+/// One recipient's access to a shared manifest: the manifest's VEK encrypted with a public key of theirs.
+/// </summary>
+public class ManifestGrant
+{
+ /// <summary>Gets or sets the recipient this grant is for.</summary>
+ public required string RecipientUserId { get; set; }
+
+ /// <summary>Gets or sets the id of the recipient public key used to encrypt (see <see cref="GrantRecipient"/>).</summary>
+ public required Guid RecipientPublicKeyId { get; set; }
+
+ /// <summary>Gets or sets the manifest VEK encrypted with that public key (base64), decryptable only by the recipient.</summary>
+ public required string EncryptedVek { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RecipientLookupResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RecipientLookupResponse.cs
deleted file mode 100644
index ea6d6b62a..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RecipientLookupResponse.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecipientLookupResponse.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
-
-/// <summary>
-/// Response for GET /v2/Sharing/recipient. Returns the primary public key a granter uses to encrypt a shared manifest's
-/// VEK for the recipient.
-/// </summary>
-public class RecipientLookupResponse
-{
- /// <summary>Gets or sets the recipient's user id.</summary>
- public required string UserId { get; set; }
-
- /// <summary>Gets or sets the id of the recipient's primary public key (used as EncryptedVek's RecipientPublicKeyId).</summary>
- public required Guid PublicKeyId { get; set; }
-
- /// <summary>Gets or sets the recipient's primary public key (the granter encrypts the folder VEK with this).</summary>
- public required string PublicKey { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RevokeAccessRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RevokeAccessRequest.cs
deleted file mode 100644
index c70c4408b..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RevokeAccessRequest.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RevokeAccessRequest.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
-
-/// <summary>
-/// Request for POST /v2/Sharing/revoke. Removes a recipient's access to a shared manifest the caller owns.
-/// </summary>
-public class RevokeAccessRequest
-{
- /// <summary>Gets or sets the shared manifest to revoke access from (must be owned by the caller).</summary>
- public required Guid ManifestId { get; set; }
-
- /// <summary>Gets or sets the recipient user id whose grant is removed.</summary>
- public required string RecipientUserId { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMember.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMember.cs
deleted file mode 100644
index 044890c19..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMember.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ShareMember.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
-
-/// <summary>
-/// One member of a shared manifest: the owner plus every recipient holding a grant.
-/// </summary>
-public class ShareMember
-{
- /// <summary>Gets or sets the member's user id.</summary>
- public required string UserId { get; set; }
-
- /// <summary>Gets or sets the member's username.</summary>
- public string? Username { get; set; }
-
- /// <summary>Gets or sets a value indicating whether this member is the folder owner.</summary>
- public required bool IsOwner { get; set; }
-
- /// <summary>Gets or sets the algorithm of the member's grant (null for the owner, whose key is held client-side).</summary>
- public string? Algorithm { get; set; }
-
- /// <summary>Gets or sets the timestamp the member's grant was created (null for the owner).</summary>
- public DateTime? GrantedAt { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMembersResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMembersResponse.cs
deleted file mode 100644
index efbc9215c..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMembersResponse.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ShareMembersResponse.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 AliasVault.Shared.Models.WebApi.V2.Sharing;
-
-/// <summary>
-/// Response for GET /v2/Sharing/manifests/{manifestId}/members. Lists the owner and every recipient of a shared manifest.
-/// </summary>
-public class ShareMembersResponse
-{
- /// <summary>Gets or sets the members of the shared manifest (owner first, then recipients).</summary>
- public List<ShareMember> Members { get; set; } = [];
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs
index e4cca832e..efdfc487c 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs
@@ -7,6 +7,7 @@
namespace AliasVault.Shared.Models.WebApi.V2.Status;
+using AliasVault.Shared.Models.WebApi.V2.ClientActions;
using AliasVault.Shared.Models.WebApi.V2.Vault;
/// <summary>
@@ -47,4 +48,10 @@ public class StatusResponse
/// <summary>Gets or sets the latest revision for each data-bucket kind the user has. Empty when none stored.</summary>
public List<BucketRevision> BucketRevisions { get; set; } = [];
+
+ /// <summary>
+ /// Gets or sets the work the server needs this client to carry out, because it needs something only a client has:
+ /// vault content, a vault key, a private key. This primarily affects vault sharing and revocation actions.
+ /// </summary>
+ public List<PendingClientAction> PendingActions { get; set; } = [];
}