1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-27 22:26:13 -05:00

add feature flag

This commit is contained in:
Brandon 2025-06-09 16:16:19 -04:00
parent 4d8d8f24dd
commit 7f3363cbc7
No known key found for this signature in database
GPG Key ID: A0E0EF0B207BA40D
2 changed files with 34 additions and 7 deletions

View File

@ -1,9 +1,12 @@
using System.Net;
using Bit.Api.AdminConsole.Public.Models.Request;
using Bit.Api.Models.Public.Response;
using Bit.Core;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -14,18 +17,24 @@ namespace Bit.Api.AdminConsole.Public.Controllers;
[Authorize("Organization")]
public class OrganizationController : Controller
{
private readonly IOrganizationService _organizationService;
private readonly ICurrentContext _currentContext;
private readonly GlobalSettings _globalSettings;
private readonly IImportOrganizationUserCommand _importOrganizationUserCommand;
private readonly IFeatureService _featureService;
public OrganizationController(
IOrganizationService organizationService,
ICurrentContext currentContext,
GlobalSettings globalSettings,
IImportOrganizationUserCommand importOrganizationUserCommand)
IImportOrganizationUserCommand importOrganizationUserCommand,
IFeatureService featureService)
{
_organizationService = organizationService;
_currentContext = currentContext;
_globalSettings = globalSettings;
_importOrganizationUserCommand = importOrganizationUserCommand;
_featureService = featureService;
}
/// <summary>
@ -46,12 +55,26 @@ public class OrganizationController : Controller
throw new BadRequestException("You cannot import this much data at once.");
}
if (_featureService.IsEnabled(FeatureFlagKeys.ScimInviteUserOptimization))
{
await _importOrganizationUserCommand.ImportAsync(
_currentContext.OrganizationId.Value,
model.Groups.Select(g => g.ToImportedGroup(_currentContext.OrganizationId.Value)),
model.Members.Where(u => !u.Deleted).Select(u => u.ToImportedOrganizationUser()),
model.Members.Where(u => u.Deleted).Select(u => u.ExternalId),
model.OverwriteExisting.GetValueOrDefault());
}
else
{
await _organizationService.ImportAsync(
_currentContext.OrganizationId.Value,
model.Groups.Select(g => g.ToImportedGroup(_currentContext.OrganizationId.Value)),
model.Members.Where(u => !u.Deleted).Select(u => u.ToImportedOrganizationUser()),
model.Members.Where(u => u.Deleted).Select(u => u.ExternalId),
model.OverwriteExisting.GetValueOrDefault(),
EventSystemUser.PublicApi
);
}
return new OkResult();
}
}

View File

@ -1,5 +1,6 @@
using System.Security.Claims;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.AdminConsole.Models.Business;
using Bit.Core.Auth.Enums;
using Bit.Core.Entities;
using Bit.Core.Enums;
@ -33,6 +34,9 @@ public interface IOrganizationService
Task<IEnumerable<Tuple<OrganizationUser, string>>> ResendInvitesAsync(Guid organizationId, Guid? invitingUserId, IEnumerable<Guid> organizationUsersId);
Task ResendInviteAsync(Guid organizationId, Guid? invitingUserId, Guid organizationUserId, bool initOrganization = false);
Task UpdateUserResetPasswordEnrollmentAsync(Guid organizationId, Guid userId, string resetPasswordKey, Guid? callingUserId);
Task ImportAsync(Guid organizationId, IEnumerable<ImportedGroup> groups,
IEnumerable<ImportedOrganizationUser> newUsers, IEnumerable<string> removeUserExternalIds,
bool overwriteExisting, EventSystemUser eventSystemUser);
Task DeleteSsoUserAsync(Guid userId, Guid? organizationId);
Task RevokeUserAsync(OrganizationUser organizationUser, Guid? revokingUserId);
Task RevokeUserAsync(OrganizationUser organizationUser, EventSystemUser systemUser);