1
0
mirror of https://github.com/bitwarden/server synced 2026-01-07 11:03:37 +00:00

[AC-1124] Restrict admins from accessing items in Collections tab (#3676)

* [AC-1124] Add GetManyUnassignedOrganizationDetailsByOrganizationIdAsync to the CipherRepository

* [AC-1124] Introduce IOrganizationCiphersQuery.cs to replace some CipherService queries

* [AC-1124] Add additional CipherDetails model that includes CollectionIds

* [AC-1124] Update CiphersController and response models
- Add new endpoint for assigned ciphers
- Update existing endpoint to only return all ciphers when feature flag is enabled the user has access

* [AC-1124] Add migration script

* [AC-1124] Add follow up ticket for Todos

* [AC-1124] Fix feature service usage after merge with main

* [AC-1124] Optimize unassigned ciphers query

* [AC-1124] Update migration script date

* [AC-1124] Update migration script date

* [AC-1124] Formatting
This commit is contained in:
Shane Melton
2024-02-08 14:07:58 -08:00
committed by GitHub
parent 058f1822ed
commit 636f716d62
14 changed files with 470 additions and 11 deletions

View File

@@ -1,4 +1,6 @@
namespace Bit.Core.Vault.Models.Data;
using Bit.Core.Entities;
namespace Bit.Core.Vault.Models.Data;
public class CipherDetails : CipherOrganizationDetails
{
@@ -7,3 +9,57 @@ public class CipherDetails : CipherOrganizationDetails
public bool Edit { get; set; }
public bool ViewPassword { get; set; }
}
public class CipherDetailsWithCollections : CipherDetails
{
public CipherDetailsWithCollections(
CipherDetails cipher,
Dictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict)
{
Id = cipher.Id;
UserId = cipher.UserId;
OrganizationId = cipher.OrganizationId;
Type = cipher.Type;
Data = cipher.Data;
Favorites = cipher.Favorites;
Folders = cipher.Folders;
Attachments = cipher.Attachments;
CreationDate = cipher.CreationDate;
RevisionDate = cipher.RevisionDate;
DeletedDate = cipher.DeletedDate;
Reprompt = cipher.Reprompt;
Key = cipher.Key;
FolderId = cipher.FolderId;
Favorite = cipher.Favorite;
Edit = cipher.Edit;
ViewPassword = cipher.ViewPassword;
CollectionIds = collectionCiphersGroupDict.TryGetValue(Id, out var value)
? value.Select(cc => cc.CollectionId)
: Array.Empty<Guid>();
}
public CipherDetailsWithCollections(CipherOrganizationDetails cipher, Dictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict)
{
Id = cipher.Id;
UserId = cipher.UserId;
OrganizationId = cipher.OrganizationId;
Type = cipher.Type;
Data = cipher.Data;
Favorites = cipher.Favorites;
Folders = cipher.Folders;
Attachments = cipher.Attachments;
CreationDate = cipher.CreationDate;
RevisionDate = cipher.RevisionDate;
DeletedDate = cipher.DeletedDate;
Reprompt = cipher.Reprompt;
Key = cipher.Key;
OrganizationUseTotp = cipher.OrganizationUseTotp;
CollectionIds = collectionCiphersGroupDict != null && collectionCiphersGroupDict.TryGetValue(Id, out var value)
? value.Select(cc => cc.CollectionId)
: Array.Empty<Guid>();
}
public IEnumerable<Guid> CollectionIds { get; set; }
}

View File

@@ -1,4 +1,5 @@
using Bit.Core.Vault.Entities;
using Bit.Core.Entities;
using Bit.Core.Vault.Entities;
namespace Bit.Core.Vault.Models.Data;
@@ -6,3 +7,31 @@ public class CipherOrganizationDetails : Cipher
{
public bool OrganizationUseTotp { get; set; }
}
public class CipherOrganizationDetailsWithCollections : CipherOrganizationDetails
{
public CipherOrganizationDetailsWithCollections(
CipherOrganizationDetails cipher,
Dictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict)
{
Id = cipher.Id;
UserId = cipher.UserId;
OrganizationId = cipher.OrganizationId;
Type = cipher.Type;
Data = cipher.Data;
Favorites = cipher.Favorites;
Folders = cipher.Folders;
Attachments = cipher.Attachments;
CreationDate = cipher.CreationDate;
RevisionDate = cipher.RevisionDate;
DeletedDate = cipher.DeletedDate;
Reprompt = cipher.Reprompt;
Key = cipher.Key;
OrganizationUseTotp = cipher.OrganizationUseTotp;
CollectionIds = collectionCiphersGroupDict.TryGetValue(Id, out var value)
? value.Select(cc => cc.CollectionId)
: Array.Empty<Guid>();
}
public IEnumerable<Guid> CollectionIds { get; set; }
}