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

Support large organization sync (#1311)

* Increase organization max seat size from 30k to 2b (#1274)

* Increase organization max seat size from 30k to 2b

* PR review. Do not modify unless state matches expected

* Organization sync simultaneous event reporting (#1275)

* Split up azure messages according to max size

* Allow simultaneous login of organization user events

* Early resolve small event lists

* Clarify logic

Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>

* Improve readability

This comes at the cost of multiple serializations, but the
 improvement in wire-time should more than make up for this
 on message where serialization time matters

Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>

* Queue emails (#1286)

* Extract common Azure queue methods

* Do not use internal entity framework namespace

* Prefer IEnumerable to IList unless needed

All of these implementations were just using `Count == 1`,
which is easily replicated. This will be used when abstracting Azure queues

* Add model for azure queue message

* Abstract Azure queue for reuse

* Creat service to enqueue mail messages for later processing

Azure queue mail service uses Azure queues.
Blocking just blocks until all the work is done -- This is
how emailing works today

* Provide mail queue service to DI

* Queue organization invite emails for later processing

All emails can later be added to this queue

* Create Admin hosted service to process enqueued mail messages

* Prefer constructors to static generators

* Mass delete organization users (#1287)

* Add delete many to Organization Users

* Correct formatting

* Remove erroneous migration

* Clarify parameter name

* Formatting fixes

* Simplify bump account revision sproc

* Formatting fixes

* Match file names to objects

* Indicate if large import is expected

* Early pull all existing users we were planning on inviting (#1290)

* Early pull all existing users we were planning on inviting

* Improve sproc name

* Batch upsert org users (#1289)

* Add UpsertMany sprocs to OrganizationUser

* Add method to create TVPs from any object.

Uses DbOrder attribute to generate.
Sproc will fail unless TVP column order matches that of the db type

* Combine migrations

* Correct formatting

* Include sql objects in sql project

* Keep consisten parameter names

* Batch deletes for performance

* Correct formatting

* consolidate migrations

* Use batch methods in OrganizationImport

* Declare @BatchSize

* Transaction names limited to 32 chars

Drop sproc before creating it if it exists

* Update import tests

* Allow for more users in org upgrades

* Fix formatting

* Improve class hierarchy structure

* Use name tuple types

* Fix formatting

* Front load all reflection

* Format constructor

* Simplify ToTvp as class-specific extension

Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
This commit is contained in:
Matt Gibson
2021-05-17 09:43:02 -05:00
committed by GitHub
parent 738a4c2bac
commit 785e788cb6
64 changed files with 1704 additions and 234 deletions

View File

@ -20,6 +20,10 @@ namespace Bit.Core.Models.Api.Public
/// </summary>
[Required]
public bool? OverwriteExisting { get; set; }
/// <summary>
/// Indicates an import of over 2000 users and/or groups is expected
/// </summary>
public bool LargeImport { get; set; } = false;
public class OrganizationImportGroupRequestModel
{

View File

@ -11,6 +11,7 @@ namespace Bit.Core.Models.Api
public Group[] Groups { get; set; }
public User[] Users { get; set; }
public bool OverwriteExisting { get; set; }
public bool LargeImport { get; set; }
public class Group
{

View File

@ -24,8 +24,8 @@ namespace Bit.Core.Models.Api
public OrganizationKeysRequestModel Keys { get; set; }
public PaymentMethodType? PaymentMethodType { get; set; }
public string PaymentToken { get; set; }
[Range(0, double.MaxValue)]
public short AdditionalSeats { get; set; }
[Range(0, int.MaxValue)]
public int AdditionalSeats { get; set; }
[Range(0, 99)]
public short? AdditionalStorageGb { get; set; }
public bool PremiumAccessAddon { get; set; }

View File

@ -9,8 +9,8 @@ namespace Bit.Core.Models.Api
[StringLength(50)]
public string BusinessName { get; set; }
public PlanType PlanType { get; set; }
[Range(0, double.MaxValue)]
public short AdditionalSeats { get; set; }
[Range(0, int.MaxValue)]
public int AdditionalSeats { get; set; }
[Range(0, 99)]
public short? AdditionalStorageGb { get; set; }
public bool PremiumAccessAddon { get; set; }

View File

@ -58,7 +58,7 @@ namespace Bit.Core.Models.Api
public string BillingEmail { get; set; }
public PlanResponseModel Plan { get; set; }
public PlanType PlanType { get; set; }
public short? Seats { get; set; }
public int? Seats { get; set; }
public short? MaxCollections { get; set; }
public short? MaxStorageGb { get; set; }
public bool UsePolicies { get; set; }

View File

@ -67,7 +67,7 @@ namespace Bit.Core.Models.Api
public short? MaxUsers { get; set; }
public bool HasAdditionalSeatsOption { get; set; }
public short? MaxAdditionalSeats { get; set; }
public int? MaxAdditionalSeats { get; set; }
public bool HasAdditionalStorageOption { get; set; }
public short? MaxAdditionalStorage { get; set; }
public bool HasPremiumAccessOption { get; set; }

View File

@ -100,7 +100,7 @@ namespace Bit.Core.Models.Business
public bool Enabled { get; set; }
public string Plan { get; set; }
public PlanType PlanType { get; set; }
public short? Seats { get; set; }
public int? Seats { get; set; }
public short? MaxCollections { get; set; }
public bool UsePolicies { get; set; }
public bool UseSso { get; set; }

View File

@ -6,7 +6,7 @@ namespace Bit.Core.Models.Business
{
public string BusinessName { get; set; }
public PlanType Plan { get; set; }
public short AdditionalSeats { get; set; }
public int AdditionalSeats { get; set; }
public short AdditionalStorageGb { get; set; }
public bool PremiumAccessAddon { get; set; }
public TaxInfo TaxInfo { get; set; }

View File

@ -42,7 +42,7 @@ namespace Bit.Core.Models.Business
public PlanType? PlanType { get; set; }
public short? Seats { get; set; }
public int? Seats { get; set; }
public short? Storage { get; set; }

View File

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace Bit.Core.Models.Mail
{
public interface IMailQueueMessage
{
string Subject { get; set; }
IEnumerable<string> ToEmails { get; set; }
IEnumerable<string> BccEmails { get; set; }
string Category { get; set; }
string TemplateName { get; set; }
object Model { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System.Collections.Generic;
namespace Bit.Core.Models.Mail
{
public class MailQueueMessage : IMailQueueMessage
{
public string Subject { get; set; }
public IEnumerable<string> ToEmails { get; set; }
public IEnumerable<string> BccEmails { get; set; }
public string Category { get; set; }
public string TemplateName { get; set; }
public object Model { get; set; }
public MailQueueMessage() { }
public MailQueueMessage(MailMessage message, string templateName, object model)
{
Subject = message.Subject;
ToEmails = message.ToEmails;
BccEmails = message.BccEmails;
Category = string.IsNullOrEmpty(message.Category) ? templateName : message.Category;
TemplateName = templateName;
Model = model;
}
}
}

View File

@ -17,7 +17,7 @@ namespace Bit.Core.Models.StaticStore
public short? MaxUsers { get; set; }
public bool HasAdditionalSeatsOption { get; set; }
public short? MaxAdditionalSeats { get; set; }
public int? MaxAdditionalSeats { get; set; }
public bool HasAdditionalStorageOption { get; set; }
public short? MaxAdditionalStorage { get; set; }
public bool HasPremiumAccessOption { get; set; }

View File

@ -23,7 +23,7 @@ namespace Bit.Core.Models.Table
public string BillingEmail { get; set; }
public string Plan { get; set; }
public PlanType PlanType { get; set; }
public short? Seats { get; set; }
public int? Seats { get; set; }
public short? MaxCollections { get; set; }
public bool UsePolicies { get; set; }
public bool UseSso { get; set; }