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

Turn on LimitCollectionCreationDeletionSplit for self host #35

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

lizard-boy
Copy link

@lizard-boy lizard-boy commented Oct 19, 2024

🎟️ Tracking

🧵 Jira Ticket: PM-10863

📚 Stacked PRs

  1. server: Split LimitCollectionCreationDeletion into two database columns bitwarden/server#4709
  2. server: Split Organization.LimitCollectionCreationDeletion into two separate business rules bitwarden/server#4730
  3. clients: Split Organization.LimitCollectionCreationDeletion into two separate business rules bitwarden/clients#11223
  4. server: Turn on LimitCollectionCreationDeletionSplit for self host bitwarden/server#4808
    ⬆️ YOU ARE HERE
  5. server: [PM-14821] [PM-14822] Remove LimitCollectionCreationDeletionSplit feature flag bitwarden/server#4809
  6. clients: [PM-14821] Remove LimitCollectionCreationDeletionSplit feature flag bitwarden/clients#11258
  7. server: Drop LimitCollectionCreationDeletion from the database bitwarden/server#4810

📔 Objective

🤳 The Bigger Picture

There is an option in the Admin Console that removes collection creation and
deletion controls from all organization members that are not in the Owner and
Admin roles. This PR stack splits this conjoined option into two separate
controls: one to block create operations and one to block delete
operations. This is a part of an effort to make these settings better align
with what customers expect it to do.

👉 This Pull Request 👍

Over the last two PRs we implemented the functional changes requested in this
body of work in server and clients. This PR is much more simple. It just
enables the feature for self hosted installations by manually setting the
feature flag to true.

This PR and the previous two in the stack encompass all of the functional
changes to the system in this PR stack. By now all requested functionality
should be deployed and available to customers. The next three pull requests
are maintenance tasks to support evolutionary database design and feature
toggling.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Greptile Summary

This pull request enables the 'LimitCollectionCreationDeletionSplit' feature for self-hosted installations, splitting the combined collection creation and deletion control into separate options.

  • Added LimitCollectionCreation and LimitCollectionDeletion properties to various models and entities, replacing the deprecated LimitCollectionCreationDeletion
  • Updated OrganizationService and UpdateOrganizationLicenseCommand to handle the new split controls
  • Modified BulkCollectionAuthorizationHandler to implement separate logic for creation and deletion permissions
  • Updated views, controllers, and repositories to support the new granular collection management controls
  • Added and modified unit and integration tests to cover the new feature functionality

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

22 file(s) reviewed, 19 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -1,4 +1,6 @@
@model OrganizationViewModel
@inject Bit.Core.Services.IFeatureService FeatureService
Copy link

Choose a reason for hiding this comment

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

style: Consider moving the IFeatureService injection to the top of the file for consistency with other injections

else
{
<dt class="col-sm-4 col-lg-3">Limit collection creation to administrators</dt>
<dd id="pm-collection-creation" class="col-sm-8 col-lg-9">@(Model.Organization.LimitCollectionCreation ? "On" : "Off")</dd>
Copy link

Choose a reason for hiding this comment

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

style: Update id attribute to 'pm-collection-creation-limit' for clarity

<dd id="pm-collection-creation" class="col-sm-8 col-lg-9">@(Model.Organization.LimitCollectionCreation ? "On" : "Off")</dd>

<dt class="col-sm-4 col-lg-3">Limit collection deletion to administrators</dt>
<dd id="pm-collection-deletion" class="col-sm-8 col-lg-9">@(Model.Organization.LimitCollectionDeletion ? "On" : "Off")</dd>
Copy link

Choose a reason for hiding this comment

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

style: Add id attribute 'pm-collection-deletion-limit' for consistency

!_featureService.IsEnabled(FeatureFlagKeys.LimitCollectionCreationDeletionSplit)
)
{
throw new BadRequestException("Only allowed when not self hosted.");
Copy link

Choose a reason for hiding this comment

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

style: Consider using a more specific error message that explains why this operation is not allowed for self-hosted installations when the feature is disabled

Comment on lines +106 to 107
// Deperectated: https://bitwarden.atlassian.net/browse/PM-10863
public bool LimitCollectionCreationDeletion { get; set; }
Copy link

Choose a reason for hiding this comment

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

syntax: Typo in 'Deprecated'

Comment on lines +43 to +44
public bool LimitCollectionCreation { get; set; }
public bool LimitCollectionDeletion { get; set; }
Copy link

Choose a reason for hiding this comment

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

style: Consider adding XML documentation comments for these new properties to explain their purpose and usage

/// properties that were added for versions 14 and 15. These properties
/// were later removed! When you increment to version 16 please delete
/// this comment.
/// </remarks>
public const int CurrentLicenseFileVersion = 14;
Copy link

Choose a reason for hiding this comment

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

logic: CurrentLicenseFileVersion is set to 14, but the ValidLicenseVersion check allows up to version 15. Consider aligning these values.

Comment on lines +36 to +39
// `LimitCollectonCreationDeletionSplit` feature flag state isn't
// relevant for this test. The flag is never checked for in this
// test. This is asserted below.
ArrangeOrganizationAbility_WithLimitCollectionCreationDeletionSplitFeatureEnabled(sutProvider, organization, true, true);
Copy link

Choose a reason for hiding this comment

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

style: Consider moving this comment to a more general location if it applies to multiple tests

Comment on lines +1015 to +1018
// `LimitCollectonCreationDeletionSplit` feature flag state isn't
// relevant for this test. The flag is never checked for in this
// test. This is asserted below.
ArrangeOrganizationAbility_WithLimitCollectionCreationDeletionSplitFeatureEnabled(sutProvider, organization, true, true);
Copy link

Choose a reason for hiding this comment

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

style: This comment is duplicated from earlier in the file. Consider creating a constant or helper method for this explanation

@@ -1336,14 +1810,37 @@ public async Task CachesCollectionsWithCanManagePermissions(
await sutProvider.GetDependency<ICollectionRepository>().Received(1).GetManyByUserIdAsync(Arg.Any<Guid>());
}

private static void ArrangeOrganizationAbility(
private static void ArrangeOrganizationAbility_WithLimitCollectionCreationDeletionSplitFeatureDisabled(
Copy link

Choose a reason for hiding this comment

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

style: These two methods are very similar. Consider refactoring to reduce duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants