mirror of
https://github.com/bitwarden/server.git
synced 2025-07-06 10:32:49 -05:00
Log events from the import organization flow (#4632)
* Log events from the import organization flow * Use an interface for the `OrganizationUser` object used to log events * Log import events as being from the public api if they are * Add logging for created groups * Log proper group ids * Fix tests * Also log update events for groups * Remove private API `import` endpoint * Make `eventSystemUser` non-nullable for `ImportAsync` * Fix tests * Delete `ImportOrganizationUsersRequestModel` * Fix tests
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
using System.Text.Json;
|
||||
using Bit.Api.AdminConsole.Models.Request;
|
||||
using Bit.Api.AdminConsole.Models.Request.Organizations;
|
||||
using Bit.Api.AdminConsole.Models.Response;
|
||||
using Bit.Api.AdminConsole.Models.Response.Organizations;
|
||||
@ -312,31 +311,6 @@ public class OrganizationsController : Controller
|
||||
await _organizationService.DeleteAsync(organization);
|
||||
}
|
||||
|
||||
[HttpPost("{id}/import")]
|
||||
public async Task Import(string id, [FromBody] ImportOrganizationUsersRequestModel model)
|
||||
{
|
||||
if (!_globalSettings.SelfHosted && !model.LargeImport &&
|
||||
(model.Groups.Count() > 2000 || model.Users.Count(u => !u.Deleted) > 2000))
|
||||
{
|
||||
throw new BadRequestException("You cannot import this much data at once.");
|
||||
}
|
||||
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!await _currentContext.OrganizationAdmin(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
var userId = _userService.GetProperUserId(User);
|
||||
await _organizationService.ImportAsync(
|
||||
orgIdGuid,
|
||||
userId.Value,
|
||||
model.Groups.Select(g => g.ToImportedGroup(orgIdGuid)),
|
||||
model.Users.Where(u => !u.Deleted).Select(u => u.ToImportedOrganizationUser()),
|
||||
model.Users.Where(u => u.Deleted).Select(u => u.ExternalId),
|
||||
model.OverwriteExisting);
|
||||
}
|
||||
|
||||
[HttpPost("{id}/api-key")]
|
||||
public async Task<ApiKeyResponseModel> ApiKey(string id, [FromBody] OrganizationApiKeyRequestModel model)
|
||||
{
|
||||
|
Reference in New Issue
Block a user