1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 00:52:49 -05:00

[AC-1139] Renamed FlexibleCollectionsIsEnabled properties to UseFlexibleCollections

This commit is contained in:
Rui Tome
2023-10-30 12:38:18 +00:00
parent 9c5f580035
commit 1a56c359fa
9 changed files with 33 additions and 33 deletions

View File

@ -29,7 +29,7 @@ public class GroupsController : Controller
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private readonly IAuthorizationService _authorizationService; private readonly IAuthorizationService _authorizationService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public GroupsController( public GroupsController(
IGroupRepository groupRepository, IGroupRepository groupRepository,
@ -80,7 +80,7 @@ public class GroupsController : Controller
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<GroupDetailsResponseModel>> Get(Guid orgId) public async Task<ListResponseModel<GroupDetailsResponseModel>> Get(Guid orgId)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await Get_FC(orgId); return await Get_FC(orgId);

View File

@ -38,7 +38,7 @@ public class OrganizationUsersController : Controller
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private readonly IAuthorizationService _authorizationService; private readonly IAuthorizationService _authorizationService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public OrganizationUsersController( public OrganizationUsersController(
IOrganizationRepository organizationRepository, IOrganizationRepository organizationRepository,
@ -92,7 +92,7 @@ public class OrganizationUsersController : Controller
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<OrganizationUserUserDetailsResponseModel>> Get(Guid orgId, bool includeGroups = false, bool includeCollections = false) public async Task<ListResponseModel<OrganizationUserUserDetailsResponseModel>> Get(Guid orgId, bool includeGroups = false, bool includeCollections = false)
{ {
var authorized = FlexibleCollectionsIsEnabled var authorized = UseFlexibleCollections
? (await _authorizationService.AuthorizeAsync(User, null, OrganizationUserOperations.ReadAll(orgId))).Succeeded ? (await _authorizationService.AuthorizeAsync(User, null, OrganizationUserOperations.ReadAll(orgId))).Succeeded
: await _currentContext.ViewAllCollections(orgId) || : await _currentContext.ViewAllCollections(orgId) ||
await _currentContext.ViewAssignedCollections(orgId) || await _currentContext.ViewAssignedCollections(orgId) ||

View File

@ -50,12 +50,12 @@ public class CollectionsController : Controller
_featureService = featureService; _featureService = featureService;
} }
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
[HttpGet("{id}")] [HttpGet("{id}")]
public async Task<CollectionResponseModel> Get(Guid orgId, Guid id) public async Task<CollectionResponseModel> Get(Guid orgId, Guid id)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await Get_FC(id); return await Get_FC(id);
@ -75,7 +75,7 @@ public class CollectionsController : Controller
[HttpGet("{id}/details")] [HttpGet("{id}/details")]
public async Task<CollectionAccessDetailsResponseModel> GetDetails(Guid orgId, Guid id) public async Task<CollectionAccessDetailsResponseModel> GetDetails(Guid orgId, Guid id)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await GetDetails_FC(id); return await GetDetails_FC(id);
@ -113,7 +113,7 @@ public class CollectionsController : Controller
[HttpGet("details")] [HttpGet("details")]
public async Task<ListResponseModel<CollectionAccessDetailsResponseModel>> GetManyWithDetails(Guid orgId) public async Task<ListResponseModel<CollectionAccessDetailsResponseModel>> GetManyWithDetails(Guid orgId)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await GetManyWithDetails_FC(orgId); return await GetManyWithDetails_FC(orgId);
@ -153,7 +153,7 @@ public class CollectionsController : Controller
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<CollectionResponseModel>> Get(Guid orgId) public async Task<ListResponseModel<CollectionResponseModel>> Get(Guid orgId)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await GetByOrgId_FC(orgId); return await GetByOrgId_FC(orgId);
@ -177,7 +177,7 @@ public class CollectionsController : Controller
[HttpGet("{id}/users")] [HttpGet("{id}/users")]
public async Task<IEnumerable<SelectionReadOnlyResponseModel>> GetUsers(Guid orgId, Guid id) public async Task<IEnumerable<SelectionReadOnlyResponseModel>> GetUsers(Guid orgId, Guid id)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await GetUsers_FC(id); return await GetUsers_FC(id);
@ -195,7 +195,7 @@ public class CollectionsController : Controller
{ {
var collection = model.ToCollection(orgId); var collection = model.ToCollection(orgId);
var authorized = FlexibleCollectionsIsEnabled var authorized = UseFlexibleCollections
? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Create)).Succeeded ? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Create)).Succeeded
: await CanCreateCollection(orgId, collection.Id) || await CanEditCollectionAsync(orgId, collection.Id); : await CanCreateCollection(orgId, collection.Id) || await CanEditCollectionAsync(orgId, collection.Id);
if (!authorized) if (!authorized)
@ -214,7 +214,7 @@ public class CollectionsController : Controller
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<CollectionResponseModel> Put(Guid orgId, Guid id, [FromBody] CollectionRequestModel model) public async Task<CollectionResponseModel> Put(Guid orgId, Guid id, [FromBody] CollectionRequestModel model)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
return await Put_FC(id, model); return await Put_FC(id, model);
@ -236,7 +236,7 @@ public class CollectionsController : Controller
[HttpPut("{id}/users")] [HttpPut("{id}/users")]
public async Task PutUsers(Guid orgId, Guid id, [FromBody] IEnumerable<SelectionReadOnlyRequestModel> model) public async Task PutUsers(Guid orgId, Guid id, [FromBody] IEnumerable<SelectionReadOnlyRequestModel> model)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
await PutUsers_FC(id, model); await PutUsers_FC(id, model);
@ -283,7 +283,7 @@ public class CollectionsController : Controller
[HttpPost("{id}/delete")] [HttpPost("{id}/delete")]
public async Task Delete(Guid orgId, Guid id) public async Task Delete(Guid orgId, Guid id)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
await Delete_FC(id); await Delete_FC(id);
@ -303,7 +303,7 @@ public class CollectionsController : Controller
[HttpPost("delete")] [HttpPost("delete")]
public async Task DeleteMany(Guid orgId, [FromBody] CollectionBulkDeleteRequestModel model) public async Task DeleteMany(Guid orgId, [FromBody] CollectionBulkDeleteRequestModel model)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
var collections = await _collectionRepository.GetManyByManyIdsAsync(model.Ids); var collections = await _collectionRepository.GetManyByManyIdsAsync(model.Ids);
@ -339,7 +339,7 @@ public class CollectionsController : Controller
[HttpPost("{id}/delete-user/{orgUserId}")] [HttpPost("{id}/delete-user/{orgUserId}")]
public async Task Delete(Guid orgId, Guid id, Guid orgUserId) public async Task Delete(Guid orgId, Guid id, Guid orgUserId)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
// New flexible collections logic // New flexible collections logic
await DeleteUser_FC(id, orgUserId); await DeleteUser_FC(id, orgUserId);
@ -352,7 +352,7 @@ public class CollectionsController : Controller
private void DeprecatedPermissionsGuard() private void DeprecatedPermissionsGuard()
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF."); throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF.");
} }

View File

@ -20,7 +20,7 @@ public class BulkCollectionAuthorizationHandler : BulkAuthorizationHandler<Colle
private readonly ICollectionRepository _collectionRepository; private readonly ICollectionRepository _collectionRepository;
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public BulkCollectionAuthorizationHandler( public BulkCollectionAuthorizationHandler(
ICurrentContext currentContext, ICurrentContext currentContext,
@ -35,7 +35,7 @@ public class BulkCollectionAuthorizationHandler : BulkAuthorizationHandler<Colle
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
CollectionOperationRequirement requirement, ICollection<Collection> resources) CollectionOperationRequirement requirement, ICollection<Collection> resources)
{ {
if (!FlexibleCollectionsIsEnabled) if (!UseFlexibleCollections)
{ {
// Flexible collections is OFF, should not be using this handler // Flexible collections is OFF, should not be using this handler
throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON."); throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON.");

View File

@ -16,7 +16,7 @@ public class CollectionAuthorizationHandler : AuthorizationHandler<CollectionOpe
private readonly ICurrentContext _currentContext; private readonly ICurrentContext _currentContext;
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public CollectionAuthorizationHandler( public CollectionAuthorizationHandler(
ICurrentContext currentContext, ICurrentContext currentContext,
@ -29,7 +29,7 @@ public class CollectionAuthorizationHandler : AuthorizationHandler<CollectionOpe
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
CollectionOperationRequirement requirement) CollectionOperationRequirement requirement)
{ {
if (!FlexibleCollectionsIsEnabled) if (!UseFlexibleCollections)
{ {
// Flexible collections is OFF, should not be using this handler // Flexible collections is OFF, should not be using this handler
throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON."); throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON.");

View File

@ -16,7 +16,7 @@ public class GroupAuthorizationHandler : AuthorizationHandler<GroupOperationRequ
private readonly ICurrentContext _currentContext; private readonly ICurrentContext _currentContext;
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public GroupAuthorizationHandler( public GroupAuthorizationHandler(
ICurrentContext currentContext, ICurrentContext currentContext,
@ -29,7 +29,7 @@ public class GroupAuthorizationHandler : AuthorizationHandler<GroupOperationRequ
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
GroupOperationRequirement requirement) GroupOperationRequirement requirement)
{ {
if (!FlexibleCollectionsIsEnabled) if (!UseFlexibleCollections)
{ {
// Flexible collections is OFF, should not be using this handler // Flexible collections is OFF, should not be using this handler
throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON."); throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON.");

View File

@ -16,7 +16,7 @@ public class OrganizationUserAuthorizationHandler : AuthorizationHandler<Organiz
private readonly ICurrentContext _currentContext; private readonly ICurrentContext _currentContext;
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public OrganizationUserAuthorizationHandler( public OrganizationUserAuthorizationHandler(
ICurrentContext currentContext, ICurrentContext currentContext,
@ -29,7 +29,7 @@ public class OrganizationUserAuthorizationHandler : AuthorizationHandler<Organiz
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
OrganizationUserOperationRequirement requirement) OrganizationUserOperationRequirement requirement)
{ {
if (!FlexibleCollectionsIsEnabled) if (!UseFlexibleCollections)
{ {
// Flexible collections is OFF, should not be using this handler // Flexible collections is OFF, should not be using this handler
throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON."); throw new FeatureUnavailableException("Flexible collections is OFF when it should be ON.");

View File

@ -26,7 +26,7 @@ public class CurrentContext : ICurrentContext
private IEnumerable<ProviderOrganizationProviderDetails> _providerOrganizationProviderDetails; private IEnumerable<ProviderOrganizationProviderDetails> _providerOrganizationProviderDetails;
private IEnumerable<ProviderUserOrganizationDetails> _providerUserOrganizations; private IEnumerable<ProviderUserOrganizationDetails> _providerUserOrganizations;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, this); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, this);
public virtual HttpContext HttpContext { get; set; } public virtual HttpContext HttpContext { get; set; }
public virtual Guid? UserId { get; set; } public virtual Guid? UserId { get; set; }
@ -345,7 +345,7 @@ public class CurrentContext : ICurrentContext
public async Task<bool> EditAssignedCollections(Guid orgId) public async Task<bool> EditAssignedCollections(Guid orgId)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF."); throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF.");
} }
@ -356,7 +356,7 @@ public class CurrentContext : ICurrentContext
public async Task<bool> DeleteAssignedCollections(Guid orgId) public async Task<bool> DeleteAssignedCollections(Guid orgId)
{ {
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF."); throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF.");
} }
@ -373,7 +373,7 @@ public class CurrentContext : ICurrentContext
* This entire method will be moved to the CollectionAuthorizationHandler in the future * This entire method will be moved to the CollectionAuthorizationHandler in the future
*/ */
if (FlexibleCollectionsIsEnabled) if (UseFlexibleCollections)
{ {
throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF."); throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF.");
} }

View File

@ -59,7 +59,7 @@ public class OrganizationService : IOrganizationService
private readonly IUpdateSecretsManagerSubscriptionCommand _updateSecretsManagerSubscriptionCommand; private readonly IUpdateSecretsManagerSubscriptionCommand _updateSecretsManagerSubscriptionCommand;
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); private bool UseFlexibleCollections => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
public OrganizationService( public OrganizationService(
IOrganizationRepository organizationRepository, IOrganizationRepository organizationRepository,
@ -430,7 +430,7 @@ public class OrganizationService : IOrganizationService
await ValidateSignUpPoliciesAsync(signup.Owner.Id); await ValidateSignUpPoliciesAsync(signup.Owner.Id);
} }
var flexibleCollectionsIsEnabled = var useFlexibleCollections =
_featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
var organization = new Organization var organization = new Organization
@ -470,7 +470,7 @@ public class OrganizationService : IOrganizationService
Status = OrganizationStatusType.Created, Status = OrganizationStatusType.Created,
UsePasswordManager = true, UsePasswordManager = true,
UseSecretsManager = signup.UseSecretsManager, UseSecretsManager = signup.UseSecretsManager,
LimitCollectionCreationDeletion = !flexibleCollectionsIsEnabled LimitCollectionCreationDeletion = !useFlexibleCollections
}; };
if (signup.UseSecretsManager) if (signup.UseSecretsManager)
@ -2562,7 +2562,7 @@ public class OrganizationService : IOrganizationService
private IEnumerable<CollectionAccessSelection> ApplyManageCollectionPermissions(OrganizationUser orgUser, IEnumerable<CollectionAccessSelection> collections) private IEnumerable<CollectionAccessSelection> ApplyManageCollectionPermissions(OrganizationUser orgUser, IEnumerable<CollectionAccessSelection> collections)
{ {
if (!FlexibleCollectionsIsEnabled && (orgUser.GetPermissions()?.EditAssignedCollections ?? false)) if (!UseFlexibleCollections && (orgUser.GetPermissions()?.EditAssignedCollections ?? false))
{ {
return collections.Select(c => return collections.Select(c =>
{ {