Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-1122] Add AllowAdminAccessToAllCollectionItems setting to Organizations #3379

Merged
merged 55 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4f08039
[AC-1117] Add manage permission (#3126)
differsthecat Aug 11, 2023
cf78f12
[AC-1374] Limit collection creation/deletion to Owner/Admin (#3145)
vincentsalucci Aug 14, 2023
78bdd51
Merge branch 'master' into feature/flexible-collections
vincentsalucci Aug 14, 2023
2f45726
Merge branch 'master' into feature/flexible-collections
vincentsalucci Aug 24, 2023
d5da5bb
fix: merge conflict resolution
vincentsalucci Aug 24, 2023
e87c20c
Merge branch 'master' into feature/flexible-collections
vincentsalucci Aug 30, 2023
5dc3ca8
[AC-1174] CollectionUser and CollectionGroup authorization handlers (…
shane-melton Aug 30, 2023
e8053e2
Fix improper merge conflict resolution
shane-melton Aug 30, 2023
3dfd38c
Merge branch 'master' into feature/flexible-collections
vincentsalucci Sep 1, 2023
3c9c8ac
Merge remote-tracking branch 'origin/master' into feature/flexible-co…
eliykat Sep 4, 2023
4ac1b10
Merge branch 'master' into feature/flexible-collections
vincentsalucci Sep 12, 2023
064a28c
fix: add permission check for collection management api, refs AC-1647…
vincentsalucci Sep 12, 2023
acd3997
Merge branch 'master' into feature/flexible-collections
vincentsalucci Sep 13, 2023
34dfdc5
[AC-1125] Enforce org setting for creating/deleting collections (#3241)
vincentsalucci Sep 18, 2023
9f5fec6
Merge remote-tracking branch 'origin/master' into feature/flexible-co…
eliykat Sep 19, 2023
ffa09d1
Merge branch 'master' into feature/flexible-collections
vincentsalucci Sep 19, 2023
f2acf1c
refactor: remove organizationId from CollectionBulkDeleteRequestModel…
vincentsalucci Sep 20, 2023
2c7d02d
Merge branch 'master' into feature/flexible-collections
eliykat Sep 26, 2023
5d431ad
[AC-1174] Bulk Collection Management (#3229)
shane-melton Sep 26, 2023
a3f554a
[AC-1646] Rename LimitCollectionCdOwnerAdmin column (#3300)
eliykat Sep 26, 2023
30b91cd
Merge branch 'master' into feature/flexible-collections
eliykat Sep 27, 2023
dd10614
Merge branch 'master' into feature/flexible-collections
eliykat Sep 28, 2023
fbb7aa1
[AC-1666] Removed EditAnyCollection from Create/Delete permission che…
vincentsalucci Sep 29, 2023
279d0cc
[AC-1669] Bug - Remove obsolete assignUserId from CollectionService.S…
vincentsalucci Oct 5, 2023
0abd7c3
Merge branch 'master' into feature/flexible-collections
vincentsalucci Oct 5, 2023
fed3252
Merge remote-tracking branch 'origin/master' into feature/flexible-co…
eliykat Oct 9, 2023
6bc38ac
Merge branch 'master' into feature/flexible-collections
eliykat Oct 13, 2023
3b049a6
[AC-1713] [Flexible collections] Add feature flags to server (#3334)
eliykat Oct 17, 2023
ae18e76
Merge remote-tracking branch 'origin/master' into feature/flexible-co…
eliykat Oct 18, 2023
52e723c
Add joint codeownership for auth handlers (#3346)
eliykat Oct 22, 2023
cd376be
Merge remote-tracking branch 'origin/master' into feature/flexible-co…
eliykat Oct 22, 2023
ad27f3d
[AC-1717] Update default values for LimitCollectionCreationDeletion (…
eliykat Oct 24, 2023
d91eb23
Merge branch 'master' into feature/flexible-collections
eliykat Oct 24, 2023
9d5c5bc
Fix: add missing namespace after merging in master
eliykat Oct 24, 2023
596e0df
Fix: add missing namespace after merging in master
eliykat Oct 24, 2023
3a5c35b
[AC-1683] Fix DB migrations for new Manage permission (#3307)
shane-melton Oct 24, 2023
0fe97d7
[AC-1648] [Flexible Collections] Bump migration scripts before featur…
eliykat Oct 24, 2023
c11ba10
Merge branch 'master' into feature/flexible-collections
shane-melton Oct 24, 2023
51d1221
[AC-1727] Add AllowAdminAccessToAllCollectionItems column to Organiza…
shane-melton Oct 25, 2023
8d38740
[AC-1720] Update stored procedures and views that query the organizat…
shane-melton Oct 25, 2023
eb2d02e
[AC-1727] Add EF migrations for new DB column
shane-melton Oct 25, 2023
69706ae
[AC-1729] Update API request/response models
shane-melton Oct 25, 2023
b565bf5
[AC-1122] Add new setting to CurrentContextOrganization.cs
shane-melton Oct 25, 2023
d752f03
[AC-1122] Ensure new setting is disabled for new orgs when the featur…
shane-melton Oct 25, 2023
697f770
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 1, 2023
e6bbce7
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 1, 2023
dccd7bd
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 2, 2023
b1f2d4f
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 6, 2023
46437b4
[AC-1122] Use V1 feature flag for new setting
shane-melton Nov 13, 2023
d2cc28b
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 13, 2023
b10c700
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 15, 2023
c15d249
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 21, 2023
87f7997
[AC-1122] Formatting
shane-melton Nov 21, 2023
5ccffd8
Merge branch 'master' into vault/ac-1122/add-collection-management-se…
shane-melton Nov 27, 2023
8a3bc08
[AC-1122] Update migration script date
shane-melton Nov 27, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public OrganizationResponseModel(Organization organization, string obj = "organi
MaxAutoscaleSmSeats = organization.MaxAutoscaleSmSeats;
MaxAutoscaleSmServiceAccounts = organization.MaxAutoscaleSmServiceAccounts;
LimitCollectionCreationDeletion = organization.LimitCollectionCreationDeletion;
AllowAdminAccessToAllCollectionItems = organization.AllowAdminAccessToAllCollectionItems;
}

public Guid Id { get; set; }
Expand Down Expand Up @@ -95,6 +96,7 @@ public OrganizationResponseModel(Organization organization, string obj = "organi
public int? MaxAutoscaleSmSeats { get; set; }
public int? MaxAutoscaleSmServiceAccounts { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; }
}

public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails orga
FamilySponsorshipValidUntil = organization.FamilySponsorshipValidUntil;
AccessSecretsManager = organization.AccessSecretsManager;
LimitCollectionCreationDeletion = organization.LimitCollectionCreationDeletion;
AllowAdminAccessToAllCollectionItems = organization.AllowAdminAccessToAllCollectionItems;

if (organization.SsoConfig != null)
{
Expand Down Expand Up @@ -114,4 +115,5 @@ public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails orga
public bool? FamilySponsorshipToDelete { get; set; }
public bool AccessSecretsManager { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ namespace Bit.Api.Models.Request.Organizations;
public class OrganizationCollectionManagementUpdateRequestModel
{
public bool LimitCreateDeleteOwnerAdmin { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; }

public virtual Organization ToOrganization(Organization existingOrganization)
{
existingOrganization.LimitCollectionCreationDeletion = LimitCreateDeleteOwnerAdmin;
existingOrganization.AllowAdminAccessToAllCollectionItems = AllowAdminAccessToAllCollectionItems;
return existingOrganization;
}
}
2 changes: 2 additions & 0 deletions src/Core/Context/CurrentContextOrganization.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know this won't work, but it's fine for now for consistency. But please create a ticket similar to AC-1809 so that you can fix it once we've figured out the pattern here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will do!

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public CurrentContextOrganization(OrganizationUserOrganizationDetails orgUser)
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(orgUser.Permissions);
AccessSecretsManager = orgUser.AccessSecretsManager && orgUser.UseSecretsManager && orgUser.Enabled;
LimitCollectionCreationDeletion = orgUser.LimitCollectionCreationDeletion;
AllowAdminAccessToAllCollectionItems = orgUser.AllowAdminAccessToAllCollectionItems;
}

public Guid Id { get; set; }
public OrganizationUserType Type { get; set; }
public Permissions Permissions { get; set; } = new();
public bool AccessSecretsManager { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; }
}
8 changes: 8 additions & 0 deletions src/Core/Entities/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public class Organization : ITableObject<Guid>, ISubscriber, IStorable, IStorabl
/// Refers to the ability for an organization to limit collection creation and deletion to owners and admins only
/// </summary>
public bool LimitCollectionCreationDeletion { get; set; }
/// <summary>
/// Refers to the ability for an organization to limit owner/admin access to all collection items
/// <remarks>
/// True: Owner/admins can access all items belonging to any collections
/// False: Owner/admins can only access items for collections they are assigned
/// </remarks>
/// </summary>
public bool AllowAdminAccessToAllCollectionItems { get; set; }

public void SetNewId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ public class OrganizationUserOrganizationDetails
public int? SmSeats { get; set; }
public int? SmServiceAccounts { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public Organization ToOrganization()
MaxAutoscaleSeats = MaxAutoscaleSeats,
OwnersNotifiedOfAutoscaling = OwnersNotifiedOfAutoscaling,
LimitCollectionCreationDeletion = LimitCollectionCreationDeletion,
AllowAdminAccessToAllCollectionItems = AllowAdminAccessToAllCollectionItems
};
}
}
3 changes: 2 additions & 1 deletion src/Core/Services/Implementations/OrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ public async Task<Tuple<Organization, OrganizationUser>> SignUpAsync(Organizatio
Status = OrganizationStatusType.Created,
UsePasswordManager = true,
UseSecretsManager = signup.UseSecretsManager,
LimitCollectionCreationDeletion = !flexibleCollectionsIsEnabled
LimitCollectionCreationDeletion = !flexibleCollectionsIsEnabled,
AllowAdminAccessToAllCollectionItems = !flexibleCollectionsIsEnabled
};

if (signup.UseSecretsManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ protected override void OnModelCreating(ModelBuilder builder)
eOrganization.Property(c => c.LimitCollectionCreationDeletion)
.ValueGeneratedNever()
.HasDefaultValue(true);
eOrganization.Property(c => c.AllowAdminAccessToAllCollectionItems)
.ValueGeneratedNever()
.HasDefaultValue(true);
eOrganizationSponsorship.Property(c => c.Id).ValueGeneratedNever();
eOrganizationUser.Property(c => c.Id).ValueGeneratedNever();
ePolicy.Property(c => c.Id).ValueGeneratedNever();
Expand Down
9 changes: 6 additions & 3 deletions src/Sql/dbo/Stored Procedures/Organization_Create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
@MaxAutoscaleSmSeats INT= null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCreationDeletion BIT = 1
@LimitCollectionCreationDeletion BIT = 1,
@AllowAdminAccessToAllCollectionItems BIT = 1
AS
BEGIN
SET NOCOUNT ON
Expand Down Expand Up @@ -110,7 +111,8 @@ BEGIN
[MaxAutoscaleSmSeats],
[MaxAutoscaleSmServiceAccounts],
[SecretsManagerBeta],
[LimitCollectionCreationDeletion]
[LimitCollectionCreationDeletion],
[AllowAdminAccessToAllCollectionItems]
)
VALUES
(
Expand Down Expand Up @@ -166,6 +168,7 @@ BEGIN
@MaxAutoscaleSmSeats,
@MaxAutoscaleSmServiceAccounts,
@SecretsManagerBeta,
@LimitCollectionCreationDeletion
@LimitCollectionCreationDeletion,
@AllowAdminAccessToAllCollectionItems
)
END
6 changes: 4 additions & 2 deletions src/Sql/dbo/Stored Procedures/Organization_Update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
@MaxAutoscaleSmSeats INT = null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCreationDeletion BIT = 1
@LimitCollectionCreationDeletion BIT = 1,
@AllowAdminAccessToAllCollectionItems BIT = 1
AS
BEGIN
SET NOCOUNT ON
Expand Down Expand Up @@ -110,7 +111,8 @@ BEGIN
[MaxAutoscaleSmSeats] = @MaxAutoscaleSmSeats,
[MaxAutoscaleSmServiceAccounts] = @MaxAutoscaleSmServiceAccounts,
[SecretsManagerBeta] = @SecretsManagerBeta,
[LimitCollectionCreationDeletion] = @LimitCollectionCreationDeletion
[LimitCollectionCreationDeletion] = @LimitCollectionCreationDeletion,
[AllowAdminAccessToAllCollectionItems] = @AllowAdminAccessToAllCollectionItems
WHERE
[Id] = @Id
END
1 change: 1 addition & 0 deletions src/Sql/dbo/Tables/Organization.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
[MaxAutoscaleSmServiceAccounts] INT NULL,
[SecretsManagerBeta] BIT NOT NULL CONSTRAINT [DF_Organization_SecretsManagerBeta] DEFAULT (0),
[LimitCollectionCreationDeletion] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCreationDeletion] DEFAULT (1),
[AllowAdminAccessToAllCollectionItems] BIT NOT NULL CONSTRAINT [DF_Organization_AllowAdminAccessToAllCollectionItems] DEFAULT (1),
CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED ([Id] ASC)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ SELECT
O.[UsePasswordManager],
O.[SmSeats],
O.[SmServiceAccounts],
O.[LimitCollectionCreationDeletion]
O.[LimitCollectionCreationDeletion],
O.[AllowAdminAccessToAllCollectionItems]
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN
Expand Down
Loading
Loading