mirror of
https://github.com/bitwarden/server.git
synced 2025-06-28 06:36:15 -05:00
add feature flag
This commit is contained in:
parent
4d8d8f24dd
commit
7f3363cbc7
@ -1,9 +1,12 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using Bit.Api.AdminConsole.Public.Models.Request;
|
using Bit.Api.AdminConsole.Public.Models.Request;
|
||||||
using Bit.Api.Models.Public.Response;
|
using Bit.Api.Models.Public.Response;
|
||||||
|
using Bit.Core;
|
||||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
|
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
|
||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Settings;
|
using Bit.Core.Settings;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -14,18 +17,24 @@ namespace Bit.Api.AdminConsole.Public.Controllers;
|
|||||||
[Authorize("Organization")]
|
[Authorize("Organization")]
|
||||||
public class OrganizationController : Controller
|
public class OrganizationController : Controller
|
||||||
{
|
{
|
||||||
|
private readonly IOrganizationService _organizationService;
|
||||||
private readonly ICurrentContext _currentContext;
|
private readonly ICurrentContext _currentContext;
|
||||||
private readonly GlobalSettings _globalSettings;
|
private readonly GlobalSettings _globalSettings;
|
||||||
private readonly IImportOrganizationUserCommand _importOrganizationUserCommand;
|
private readonly IImportOrganizationUserCommand _importOrganizationUserCommand;
|
||||||
|
private readonly IFeatureService _featureService;
|
||||||
|
|
||||||
public OrganizationController(
|
public OrganizationController(
|
||||||
|
IOrganizationService organizationService,
|
||||||
ICurrentContext currentContext,
|
ICurrentContext currentContext,
|
||||||
GlobalSettings globalSettings,
|
GlobalSettings globalSettings,
|
||||||
IImportOrganizationUserCommand importOrganizationUserCommand)
|
IImportOrganizationUserCommand importOrganizationUserCommand,
|
||||||
|
IFeatureService featureService)
|
||||||
{
|
{
|
||||||
|
_organizationService = organizationService;
|
||||||
_currentContext = currentContext;
|
_currentContext = currentContext;
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
_importOrganizationUserCommand = importOrganizationUserCommand;
|
_importOrganizationUserCommand = importOrganizationUserCommand;
|
||||||
|
_featureService = featureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,12 +55,26 @@ public class OrganizationController : Controller
|
|||||||
throw new BadRequestException("You cannot import this much data at once.");
|
throw new BadRequestException("You cannot import this much data at once.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_featureService.IsEnabled(FeatureFlagKeys.ScimInviteUserOptimization))
|
||||||
|
{
|
||||||
await _importOrganizationUserCommand.ImportAsync(
|
await _importOrganizationUserCommand.ImportAsync(
|
||||||
_currentContext.OrganizationId.Value,
|
_currentContext.OrganizationId.Value,
|
||||||
model.Groups.Select(g => g.ToImportedGroup(_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.ToImportedOrganizationUser()),
|
||||||
model.Members.Where(u => u.Deleted).Select(u => u.ExternalId),
|
model.Members.Where(u => u.Deleted).Select(u => u.ExternalId),
|
||||||
model.OverwriteExisting.GetValueOrDefault());
|
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();
|
return new OkResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Bit.Core.AdminConsole.Entities;
|
using Bit.Core.AdminConsole.Entities;
|
||||||
|
using Bit.Core.AdminConsole.Models.Business;
|
||||||
using Bit.Core.Auth.Enums;
|
using Bit.Core.Auth.Enums;
|
||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
using Bit.Core.Enums;
|
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<IEnumerable<Tuple<OrganizationUser, string>>> ResendInvitesAsync(Guid organizationId, Guid? invitingUserId, IEnumerable<Guid> organizationUsersId);
|
||||||
Task ResendInviteAsync(Guid organizationId, Guid? invitingUserId, Guid organizationUserId, bool initOrganization = false);
|
Task ResendInviteAsync(Guid organizationId, Guid? invitingUserId, Guid organizationUserId, bool initOrganization = false);
|
||||||
Task UpdateUserResetPasswordEnrollmentAsync(Guid organizationId, Guid userId, string resetPasswordKey, Guid? callingUserId);
|
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 DeleteSsoUserAsync(Guid userId, Guid? organizationId);
|
||||||
Task RevokeUserAsync(OrganizationUser organizationUser, Guid? revokingUserId);
|
Task RevokeUserAsync(OrganizationUser organizationUser, Guid? revokingUserId);
|
||||||
Task RevokeUserAsync(OrganizationUser organizationUser, EventSystemUser systemUser);
|
Task RevokeUserAsync(OrganizationUser organizationUser, EventSystemUser systemUser);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user