Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/Core/AdminConsole/Entities/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,54 @@
using Bit.Core.Enums;
using Bit.Core.Utilities;

#nullable enable

namespace Bit.Core.Entities;

/// <summary>
/// A named grouping of vault items within an organization, used to share items with members and groups.
/// Access is granted to individual members via <see cref="CollectionUser"/> and to groups via <see cref="CollectionGroup"/>.
/// </summary>
public class Collection : ITableObject<Guid>
{
/// <summary>
/// A unique identifier for the collection.
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// The ID of the <see cref="Bit.Core.AdminConsole.Entities.Organization"/> that owns this collection.
/// </summary>
public Guid OrganizationId { get; set; }
/// <summary>
/// The name of the collection, stored encrypted.
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// An ID used to associate this collection with a record in external services.
/// </summary>
[MaxLength(300)]
public string? ExternalId { get; set; }
/// <summary>
/// The date the collection was created.
/// </summary>
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
/// <summary>
/// The date the collection was last updated.
/// </summary>
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
/// <summary>
/// The type of collection, indicating how it was created and how it behaves.
/// </summary>
public CollectionType Type { get; set; } = CollectionType.SharedCollection;
/// <summary>
/// Used as the name for the collection if this is a <see cref="CollectionType.DefaultUserCollection"/>
/// of a user who is no longer a member of the organization. In this case, it stores the user's
/// email address so that it is identifiable by an admin (rather than being called "My Items" for an
/// unknown user). Unencrypted.
/// </summary>
public string? DefaultUserCollectionEmail { get; set; }

/// <summary>
/// Initializes <see cref="Id"/> to a new COMB GUID.
/// </summary>
public void SetNewId()
{
Id = CoreHelpers.GenerateComb();
Expand Down
22 changes: 20 additions & 2 deletions src/Core/AdminConsole/Entities/CollectionGroup.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
namespace Bit.Core.Entities;

#nullable enable

/// <summary>
/// A join record that grants a <see cref="Bit.Core.AdminConsole.Entities.Group"/> access to a <see cref="Collection"/>
/// with specific permissions. Direct user access is represented separately by <see cref="CollectionUser"/>.
/// </summary>
public class CollectionGroup
{
/// <summary>
/// The ID of the <see cref="Collection"/> the group has access to.
/// </summary>
public Guid CollectionId { get; set; }
/// <summary>
/// The ID of the <see cref="Bit.Core.AdminConsole.Entities.Group"/> that has access to the collection.
/// </summary>
public Guid GroupId { get; set; }
/// <summary>
/// If true, group members can view items in the collection but cannot create, edit, or delete them.
/// </summary>
public bool ReadOnly { get; set; }
/// <summary>
/// If true, group members cannot see password and TOTP fields for items in the collection.
/// </summary>
public bool HidePasswords { get; set; }
/// <summary>
/// If true, group members can manage the collection itself — including renaming it,
/// deleting it, and assigning access for other users and groups.
/// </summary>
public bool Manage { get; set; }
}
22 changes: 20 additions & 2 deletions src/Core/AdminConsole/Entities/CollectionUser.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
namespace Bit.Core.Entities;

#nullable enable

/// <summary>
/// A join record that grants an <see cref="OrganizationUser"/> direct access to a <see cref="Collection"/>
/// with specific permissions. Access via group membership is represented separately by <see cref="CollectionGroup"/>.
/// </summary>
public class CollectionUser
{
/// <summary>
/// The ID of the <see cref="Collection"/> the organization user has access to.
/// </summary>
public Guid CollectionId { get; set; }
/// <summary>
/// The ID of the <see cref="OrganizationUser"/> who has access to the collection.
/// </summary>
public Guid OrganizationUserId { get; set; }
/// <summary>
/// If true, the user can view items in the collection but cannot create, edit, or delete them.
/// </summary>
public bool ReadOnly { get; set; }
/// <summary>
/// If true, the user cannot see password and TOTP fields for items in the collection.
/// </summary>
public bool HidePasswords { get; set; }
/// <summary>
/// If true, the user can manage the collection itself — including renaming it,
/// deleting it, and assigning access for other users and groups.
/// </summary>
public bool Manage { get; set; }
}
29 changes: 27 additions & 2 deletions src/Core/AdminConsole/Entities/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,46 @@
using Bit.Core.Models;
using Bit.Core.Utilities;

#nullable enable

namespace Bit.Core.AdminConsole.Entities;

/// <summary>
/// A named group of organization members, used to grant <see cref="Collection"/> access
/// to multiple members at once via <see cref="CollectionGroup"/> associations.
/// Members are associated with groups via <see cref="GroupUser"/>.
/// </summary>
public class Group : ITableObject<Guid>, IExternal
{
/// <summary>
/// A unique identifier for the group.
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// The ID of the <see cref="Organization"/> that owns this group.
/// </summary>
public Guid OrganizationId { get; set; }
/// <summary>
/// The name of the group. Unencrypted.
/// </summary>
[MaxLength(100)]
public string Name { get; set; } = null!;
/// <summary>
/// An ID used to associate this group with a record in an external directory service.
/// Used by Directory Connector and SCIM.
/// </summary>
[MaxLength(300)]
public string? ExternalId { get; set; }
/// <summary>
/// The date the group was created.
/// </summary>
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
/// <summary>
/// The date the group was last updated.
/// </summary>
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;

/// <summary>
/// Initializes <see cref="Id"/> to a new COMB GUID.
/// </summary>
public void SetNewId()
{
Id = CoreHelpers.GenerateComb();
Expand Down
12 changes: 10 additions & 2 deletions src/Core/AdminConsole/Entities/GroupUser.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
namespace Bit.Core.AdminConsole.Entities;

#nullable enable

/// <summary>
/// A join record linking an <see cref="Bit.Core.Entities.OrganizationUser"/> to a <see cref="Group"/>,
/// indicating that the organization user is a member of that group.
/// </summary>
public class GroupUser
{
/// <summary>
/// The ID of the <see cref="Group"/> the organization user belongs to.
/// </summary>
public Guid GroupId { get; set; }
/// <summary>
/// The ID of the <see cref="Bit.Core.Entities.OrganizationUser"/> that is a member of the group.
/// </summary>
public Guid OrganizationUserId { get; set; }
}
Loading
Loading