From ac8ca46f0f1adfd417873c7593f70fb52bf1bbc8 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 24 Jan 2022 12:14:04 +0100 Subject: [PATCH] Remove the u2f lib (#1820) --- .../DynamicAuthenticationSchemeProvider.cs | 4 +- .../OrganizationSsoRequestModel.cs | 4 +- src/Core/Core.csproj | 1 - src/Core/Entities/U2f.cs | 26 - src/Core/Enums/TwoFactorProviderType.cs | 2 +- src/Core/Identity/U2fTokenProvider.cs | 221 --- .../IdentityServer/BaseRequestValidator.cs | 12 - src/Core/Models/TwoFactorProvider.cs | 78 - src/Core/Repositories/IU2fRepository.cs | 13 - .../Services/Implementations/UserService.cs | 27 - .../DapperServiceCollectionExtensions.cs | 1 - .../Repositories/U2fRepository.cs | 63 - ...ityFrameworkServiceCollectionExtensions.cs | 1 - .../Models/U2f.cs | 17 - .../Models/User.cs | 1 - .../Repositories/DatabaseContext.cs | 3 - .../Repositories/U2fRepository.cs | 55 - .../Utilities/ServiceCollectionExtensions.cs | 2 - src/Sql/Sql.sqlproj | 6 - src/Sql/dbo/Stored Procedures/U2f_Create.sql | 33 - .../Stored Procedures/U2f_DeleteByUserId.sql | 12 - .../dbo/Stored Procedures/U2f_DeleteOld.sql | 20 - .../Stored Procedures/U2f_ReadByUserId.sql | 13 - .../dbo/Stored Procedures/User_DeleteById.sql | 7 - src/Sql/dbo/Tables/U2f.sql | 22 - src/Sql/dbo/Views/U2fView.sql | 6 - .../EntityFrameworkRepositoryFixtures.cs | 1 - test/Core.Test/AutoFixture/U2fFixtures.cs | 62 - .../Identity/U2fTokenProviderTests.cs | 62 - .../EqualityComparers/U2fCompare.cs | 22 - .../EntityFramework/U2fRepositoryTests.cs | 54 - .../LocalAttachmentStorageServiceTests.cs | 9 +- ...020-09-09_00-ScriptMigrateU2FToWebAuthn.cs | 121 -- .../DbScripts/2022-01-21_00_RemoveU2F.sql | 154 ++ .../20220121092546_RemoveU2F.Designer.cs | 1522 ++++++++++++++++ .../Migrations/20220121092546_RemoveU2F.cs | 52 + .../DatabaseContextModelSnapshot.cs | 222 +-- .../Scripts/2022-01-21_00_RemoveU2F.sql | Bin 0 -> 332 bytes .../20220121092321_RemoveU2F.Designer.cs | 1530 +++++++++++++++++ .../Migrations/20220121092321_RemoveU2F.cs | 47 + .../DatabaseContextModelSnapshot.cs | 223 +-- .../Scripts/2022-01-21_00_RemoveU2F.psql | Bin 0 -> 332 bytes util/Setup/AppIdBuilder.cs | 1 + util/Setup/Templates/NginxConfig.hbs | 4 - 44 files changed, 3489 insertions(+), 1247 deletions(-) delete mode 100644 src/Core/Entities/U2f.cs delete mode 100644 src/Core/Identity/U2fTokenProvider.cs delete mode 100644 src/Core/Repositories/IU2fRepository.cs delete mode 100644 src/Infrastructure.Dapper/Repositories/U2fRepository.cs delete mode 100644 src/Infrastructure.EntityFramework/Models/U2f.cs delete mode 100644 src/Infrastructure.EntityFramework/Repositories/U2fRepository.cs delete mode 100644 src/Sql/dbo/Stored Procedures/U2f_Create.sql delete mode 100644 src/Sql/dbo/Stored Procedures/U2f_DeleteByUserId.sql delete mode 100644 src/Sql/dbo/Stored Procedures/U2f_DeleteOld.sql delete mode 100644 src/Sql/dbo/Stored Procedures/U2f_ReadByUserId.sql delete mode 100644 src/Sql/dbo/Tables/U2f.sql delete mode 100644 src/Sql/dbo/Views/U2fView.sql delete mode 100644 test/Core.Test/AutoFixture/U2fFixtures.cs delete mode 100644 test/Core.Test/Identity/U2fTokenProviderTests.cs delete mode 100644 test/Core.Test/Repositories/EntityFramework/EqualityComparers/U2fCompare.cs delete mode 100644 test/Core.Test/Repositories/EntityFramework/U2fRepositoryTests.cs delete mode 100644 util/Migrator/DbScripts/2020-09-09_00-ScriptMigrateU2FToWebAuthn.cs create mode 100644 util/Migrator/DbScripts/2022-01-21_00_RemoveU2F.sql create mode 100644 util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.Designer.cs create mode 100644 util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.cs create mode 100644 util/MySqlMigrations/Scripts/2022-01-21_00_RemoveU2F.sql create mode 100644 util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.Designer.cs create mode 100644 util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.cs create mode 100644 util/PostgresMigrations/Scripts/2022-01-21_00_RemoveU2F.psql diff --git a/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs b/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs index 749bba2ad1..e8628fd6b3 100644 --- a/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs +++ b/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Bit.Core.Entities; @@ -25,7 +24,6 @@ using Microsoft.IdentityModel.Tokens; using Sustainsys.Saml2.AspNetCore2; using Sustainsys.Saml2.Configuration; using Sustainsys.Saml2.Saml2P; -using U2F.Core.Utils; namespace Bit.Core.Business.Sso { @@ -412,7 +410,7 @@ namespace Bit.Core.Business.Sso } if (!string.IsNullOrWhiteSpace(config.IdpX509PublicCert)) { - var cert = config.IdpX509PublicCert.Base64StringToByteArray(); + var cert = CoreHelpers.Base64UrlDecode(config.IdpX509PublicCert); idp.SigningKeys.AddConfiguredKey(new X509Certificate2(cert)); } // This must happen last since it calls Validate() internally. diff --git a/src/Api/Models/Request/Organizations/OrganizationSsoRequestModel.cs b/src/Api/Models/Request/Organizations/OrganizationSsoRequestModel.cs index 77d8b0e342..ae10ce78d9 100644 --- a/src/Api/Models/Request/Organizations/OrganizationSsoRequestModel.cs +++ b/src/Api/Models/Request/Organizations/OrganizationSsoRequestModel.cs @@ -9,8 +9,8 @@ using Bit.Core.Enums; using Bit.Core.Models.Data; using Bit.Core.Services; using Bit.Core.Sso; +using Bit.Core.Utilities; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using U2F.Core.Utils; namespace Bit.Api.Models.Request.Organizations { @@ -147,7 +147,7 @@ namespace Bit.Api.Models.Request.Organizations ValidationResult failedResult = null; try { - var certData = StripPemCertificateElements(IdpX509PublicCert).Base64StringToByteArray(); + var certData = CoreHelpers.Base64UrlDecode(StripPemCertificateElements(IdpX509PublicCert)); new X509Certificate2(certData); } catch (FormatException) diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index b70d79092d..44f96360fe 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -50,7 +50,6 @@ - diff --git a/src/Core/Entities/U2f.cs b/src/Core/Entities/U2f.cs deleted file mode 100644 index 3e8a187e6b..0000000000 --- a/src/Core/Entities/U2f.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace Bit.Core.Entities -{ - public class U2f : ITableObject - { - public int Id { get; set; } - public Guid UserId { get; set; } - [MaxLength(200)] - public string KeyHandle { get; set; } - [MaxLength(200)] - public string Challenge { get; set; } - [MaxLength(50)] - public string AppId { get; set; } - [MaxLength(20)] - public string Version { get; set; } - public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; - - public void SetNewId() - { - // int will be auto-populated - Id = 0; - } - } -} diff --git a/src/Core/Enums/TwoFactorProviderType.cs b/src/Core/Enums/TwoFactorProviderType.cs index d3d0c195ae..3779d5adde 100644 --- a/src/Core/Enums/TwoFactorProviderType.cs +++ b/src/Core/Enums/TwoFactorProviderType.cs @@ -6,7 +6,7 @@ Email = 1, Duo = 2, YubiKey = 3, - U2f = 4, + // U2f = 4, // Deprecated Remember = 5, OrganizationDuo = 6, WebAuthn = 7, diff --git a/src/Core/Identity/U2fTokenProvider.cs b/src/Core/Identity/U2fTokenProvider.cs deleted file mode 100644 index fa3b5d3fcd..0000000000 --- a/src/Core/Identity/U2fTokenProvider.cs +++ /dev/null @@ -1,221 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; -using Bit.Core.Entities; -using Bit.Core.Enums; -using Bit.Core.Models; -using Bit.Core.Repositories; -using Bit.Core.Services; -using Bit.Core.Settings; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.DependencyInjection; -using U2F.Core.Exceptions; -using U2F.Core.Models; -using U2F.Core.Utils; -using U2fLib = U2F.Core.Crypto.U2F; - -namespace Bit.Core.Identity -{ - public class U2fTokenProvider : IUserTwoFactorTokenProvider - { - private readonly IServiceProvider _serviceProvider; - private readonly IU2fRepository _u2fRepository; - private readonly GlobalSettings _globalSettings; - - public U2fTokenProvider( - IServiceProvider serviceProvider, - IU2fRepository u2fRepository, - GlobalSettings globalSettings) - { - _serviceProvider = serviceProvider; - _u2fRepository = u2fRepository; - _globalSettings = globalSettings; - } - - public async Task CanGenerateTwoFactorTokenAsync(UserManager manager, User user) - { - var userService = _serviceProvider.GetRequiredService(); - if (!(await userService.CanAccessPremium(user))) - { - return false; - } - - var provider = user.GetTwoFactorProvider(TwoFactorProviderType.U2f); - if (!HasProperMetaData(provider)) - { - return false; - } - - return await userService.TwoFactorProviderIsEnabledAsync(TwoFactorProviderType.U2f, user); - } - - public async Task GenerateAsync(string purpose, UserManager manager, User user) - { - var userService = _serviceProvider.GetRequiredService(); - if (!(await userService.CanAccessPremium(user))) - { - return null; - } - - var provider = user.GetTwoFactorProvider(TwoFactorProviderType.U2f); - var keys = LoadKeys(provider); - if (keys.Count == 0) - { - return null; - } - - await _u2fRepository.DeleteManyByUserIdAsync(user.Id); - - try - { - var challengeBytes = U2fLib.Crypto.GenerateChallenge(); - var appId = Utilities.CoreHelpers.U2fAppIdUrl(_globalSettings); - var oldChallenges = new List(); - var challengeKeys = new List(); - foreach (var key in keys) - { - var registration = new DeviceRegistration(key.Item2.KeyHandleBytes, key.Item2.PublicKeyBytes, - key.Item2.CertificateBytes, key.Item2.Counter); - var auth = U2fLib.StartAuthentication(appId, registration, challengeBytes); - - // TODO: Maybe move this to a bulk create? - await _u2fRepository.CreateAsync(new U2f - { - AppId = auth.AppId, - Challenge = auth.Challenge, - KeyHandle = auth.KeyHandle, - Version = auth.Version, - UserId = user.Id, - CreationDate = DateTime.UtcNow - }); - - challengeKeys.Add(new - { - keyHandle = auth.KeyHandle, - version = auth.Version - }); - - // TODO: Old challenges array is here for backwards compat. Remove in the future. - oldChallenges.Add(new - { - appId = auth.AppId, - challenge = auth.Challenge, - keyHandle = auth.KeyHandle, - version = auth.Version - }); - } - - var oldToken = JsonSerializer.Serialize(oldChallenges); - var token = JsonSerializer.Serialize(new - { - appId = appId, - challenge = challengeBytes.ByteArrayToBase64String(), - keys = challengeKeys - }); - return $"{token}|{oldToken}"; - } - catch (U2fException) - { - return null; - } - } - - public async Task ValidateAsync(string purpose, string token, UserManager manager, User user) - { - var userService = _serviceProvider.GetRequiredService(); - if (!(await userService.CanAccessPremium(user)) || string.IsNullOrWhiteSpace(token)) - { - return false; - } - - var provider = user.GetTwoFactorProvider(TwoFactorProviderType.U2f); - var keys = LoadKeys(provider); - if (keys.Count == 0) - { - return false; - } - - var authenticateResponse = BaseModel.FromJson(token); - var key = keys.FirstOrDefault(f => f.Item2.KeyHandle == authenticateResponse.KeyHandle); - - if (key == null) - { - return false; - } - - var challenges = await _u2fRepository.GetManyByUserIdAsync(user.Id); - if (challenges.Count == 0) - { - return false; - } - - // User will have a authentication request for each device they have registered so get the one that matches - // the device key handle - var challenge = challenges.FirstOrDefault(c => c.KeyHandle == authenticateResponse.KeyHandle); - if (challenge == null) - { - return false; - } - - var success = true; - var registration = new DeviceRegistration(key.Item2.KeyHandleBytes, key.Item2.PublicKeyBytes, - key.Item2.CertificateBytes, key.Item2.Counter); - try - { - var auth = new StartedAuthentication(challenge.Challenge, challenge.AppId, challenge.KeyHandle); - U2fLib.FinishAuthentication(auth, authenticateResponse, registration); - } - catch (U2fException) - { - success = false; - } - - // Update database - await _u2fRepository.DeleteManyByUserIdAsync(user.Id); - key.Item2.Counter = registration.Counter; - if (key.Item2.Counter > 0) - { - key.Item2.Compromised = registration.IsCompromised; - } - - var providers = user.GetTwoFactorProviders(); - providers[TwoFactorProviderType.U2f].MetaData[key.Item1] = key.Item2; - user.SetTwoFactorProviders(providers); - await manager.UpdateAsync(user); - - return success; - } - - private bool HasProperMetaData(TwoFactorProvider provider) - { - return (provider?.MetaData?.Count ?? 0) > 0; - } - - private List> LoadKeys(TwoFactorProvider provider) - { - var keys = new List>(); - if (!HasProperMetaData(provider)) - { - return keys; - } - - // Support up to 5 keys - for (var i = 1; i <= 5; i++) - { - var keyName = $"Key{i}"; - if (provider.MetaData.ContainsKey(keyName)) - { - var key = new TwoFactorProvider.U2fMetaData((dynamic)provider.MetaData[keyName]); - if (!key?.Compromised ?? false) - { - keys.Add(new Tuple(keyName, key)); - } - } - } - - return keys; - } - } -} diff --git a/src/Core/IdentityServer/BaseRequestValidator.cs b/src/Core/IdentityServer/BaseRequestValidator.cs index e47df16b49..c562495f73 100644 --- a/src/Core/IdentityServer/BaseRequestValidator.cs +++ b/src/Core/IdentityServer/BaseRequestValidator.cs @@ -375,7 +375,6 @@ namespace Bit.Core.IdentityServer case TwoFactorProviderType.Email: case TwoFactorProviderType.Duo: case TwoFactorProviderType.YubiKey: - case TwoFactorProviderType.U2f: case TwoFactorProviderType.WebAuthn: case TwoFactorProviderType.Remember: if (type != TwoFactorProviderType.Remember && @@ -403,7 +402,6 @@ namespace Bit.Core.IdentityServer switch (type) { case TwoFactorProviderType.Duo: - case TwoFactorProviderType.U2f: case TwoFactorProviderType.WebAuthn: case TwoFactorProviderType.Email: case TwoFactorProviderType.YubiKey: @@ -422,16 +420,6 @@ namespace Bit.Core.IdentityServer ["Signature"] = token }; } - else if (type == TwoFactorProviderType.U2f) - { - // TODO: Remove "Challenges" in a future update. Deprecated. - var tokens = token?.Split('|'); - return new Dictionary - { - ["Challenge"] = tokens != null && tokens.Length > 0 ? tokens[0] : null, - ["Challenges"] = tokens != null && tokens.Length > 1 ? tokens[1] : null - }; - } else if (type == TwoFactorProviderType.WebAuthn) { if (token == null) diff --git a/src/Core/Models/TwoFactorProvider.cs b/src/Core/Models/TwoFactorProvider.cs index 64ccd7bde9..7b644940d9 100644 --- a/src/Core/Models/TwoFactorProvider.cs +++ b/src/Core/Models/TwoFactorProvider.cs @@ -1,12 +1,8 @@ using System; using System.Collections.Generic; -using System.Security.Cryptography; -using System.Text.Json.Serialization; using Bit.Core.Enums; using Bit.Core.Utilities; using Fido2NetLib.Objects; -using PeterO.Cbor; -using U2F.Core.Utils; namespace Bit.Core.Models { @@ -15,79 +11,6 @@ namespace Bit.Core.Models public bool Enabled { get; set; } public Dictionary MetaData { get; set; } = new Dictionary(); - public class U2fMetaData - { - public U2fMetaData() { } - - public U2fMetaData(dynamic o) - { - Name = o.Name; - KeyHandle = o.KeyHandle; - PublicKey = o.PublicKey; - Certificate = o.Certificate; - Counter = o.Counter; - Compromised = o.Compromised; - } - - public string Name { get; set; } - public string KeyHandle { get; set; } - [JsonIgnore] - public byte[] KeyHandleBytes => - string.IsNullOrWhiteSpace(KeyHandle) ? null : Utils.Base64StringToByteArray(KeyHandle); - public string PublicKey { get; set; } - [JsonIgnore] - public byte[] PublicKeyBytes => - string.IsNullOrWhiteSpace(PublicKey) ? null : Utils.Base64StringToByteArray(PublicKey); - public string Certificate { get; set; } - [JsonIgnore] - public byte[] CertificateBytes => - string.IsNullOrWhiteSpace(Certificate) ? null : Utils.Base64StringToByteArray(Certificate); - public uint Counter { get; set; } - public bool Compromised { get; set; } - - private static CBORObject CreatePublicKeyFromU2fRegistrationData(byte[] keyHandleData, byte[] publicKeyData) - { - var x = new byte[32]; - var y = new byte[32]; - Buffer.BlockCopy(publicKeyData, 1, x, 0, 32); - Buffer.BlockCopy(publicKeyData, 33, y, 0, 32); - - var point = new ECPoint - { - X = x, - Y = y, - }; - - var coseKey = CBORObject.NewMap(); - - coseKey.Add(COSE.KeyCommonParameter.KeyType, COSE.KeyType.EC2); - coseKey.Add(COSE.KeyCommonParameter.Alg, -7); - - coseKey.Add(COSE.KeyTypeParameter.Crv, COSE.EllipticCurve.P256); - - coseKey.Add(COSE.KeyTypeParameter.X, point.X); - coseKey.Add(COSE.KeyTypeParameter.Y, point.Y); - - return coseKey; - } - - public WebAuthnData ToWebAuthnData() - { - return new WebAuthnData - { - Name = Name, - Descriptor = new PublicKeyCredentialDescriptor - { - Id = KeyHandleBytes, - Type = PublicKeyCredentialType.PublicKey - }, - PublicKey = CreatePublicKeyFromU2fRegistrationData(KeyHandleBytes, PublicKeyBytes).EncodeToBytes(), - SignatureCounter = Counter, - Migrated = true, - }; - } - } - public class WebAuthnData { public WebAuthnData() { } @@ -130,7 +53,6 @@ namespace Bit.Core.Models { case TwoFactorProviderType.Duo: case TwoFactorProviderType.YubiKey: - case TwoFactorProviderType.U2f: case TwoFactorProviderType.WebAuthn: return true; default: diff --git a/src/Core/Repositories/IU2fRepository.cs b/src/Core/Repositories/IU2fRepository.cs deleted file mode 100644 index 7246b112c2..0000000000 --- a/src/Core/Repositories/IU2fRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Bit.Core.Entities; - -namespace Bit.Core.Repositories -{ - public interface IU2fRepository : IRepository - { - Task> GetManyByUserIdAsync(Guid userId); - Task DeleteManyByUserIdAsync(Guid userId); - } -} diff --git a/src/Core/Services/Implementations/UserService.cs b/src/Core/Services/Implementations/UserService.cs index 575a3763e8..cd7b0e7191 100644 --- a/src/Core/Services/Implementations/UserService.cs +++ b/src/Core/Services/Implementations/UserService.cs @@ -21,7 +21,6 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using File = System.IO.File; -using U2fLib = U2F.Core.Crypto.U2F; namespace Bit.Core.Services { @@ -481,25 +480,6 @@ namespace Bit.Core.Services return false; } - // Delete U2F token is this is a migrated WebAuthn token. - var entry = new TwoFactorProvider.WebAuthnData(provider.MetaData[keyName]); - if (entry?.Migrated ?? false) - { - var u2fProvider = user.GetTwoFactorProvider(TwoFactorProviderType.U2f); - if (u2fProvider?.MetaData?.ContainsKey(keyName) ?? false) - { - u2fProvider.MetaData.Remove(keyName); - if (u2fProvider.MetaData.Count > 0) - { - providers[TwoFactorProviderType.U2f] = u2fProvider; - } - else - { - providers.Remove(TwoFactorProviderType.U2f); - } - } - } - provider.MetaData.Remove(keyName); providers[TwoFactorProviderType.WebAuthn] = provider; user.SetTwoFactorProviders(providers); @@ -899,13 +879,6 @@ namespace Bit.Core.Services return; } - // Since the user can no longer directly manipulate U2F tokens, we should - // disable them when the user disables WebAuthn. - if (type == TwoFactorProviderType.WebAuthn) - { - providers.Remove(TwoFactorProviderType.U2f); - } - providers.Remove(type); user.SetTwoFactorProviders(providers); await SaveUserAsync(user); diff --git a/src/Infrastructure.Dapper/DapperServiceCollectionExtensions.cs b/src/Infrastructure.Dapper/DapperServiceCollectionExtensions.cs index 1dedc3c48a..9ce997fae9 100644 --- a/src/Infrastructure.Dapper/DapperServiceCollectionExtensions.cs +++ b/src/Infrastructure.Dapper/DapperServiceCollectionExtensions.cs @@ -31,7 +31,6 @@ namespace Bit.Infrastructure.Dapper services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); if (selfHosted) diff --git a/src/Infrastructure.Dapper/Repositories/U2fRepository.cs b/src/Infrastructure.Dapper/Repositories/U2fRepository.cs deleted file mode 100644 index 4b0c72a10c..0000000000 --- a/src/Infrastructure.Dapper/Repositories/U2fRepository.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Linq; -using System.Threading.Tasks; -using Bit.Core.Entities; -using Bit.Core.Repositories; -using Bit.Core.Settings; -using Dapper; - -namespace Bit.Infrastructure.Dapper.Repositories -{ - public class U2fRepository : Repository, IU2fRepository - { - public U2fRepository(GlobalSettings globalSettings) - : this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString) - { } - - public U2fRepository(string connectionString, string readOnlyConnectionString) - : base(connectionString, readOnlyConnectionString) - { } - - public async Task> GetManyByUserIdAsync(Guid userId) - { - using (var connection = new SqlConnection(ConnectionString)) - { - var results = await connection.QueryAsync( - $"[{Schema}].[U2f_ReadByUserId]", - new { UserId = userId }, - commandType: CommandType.StoredProcedure); - - return results.ToList(); - } - } - - public async Task DeleteManyByUserIdAsync(Guid userId) - { - using (var connection = new SqlConnection(ConnectionString)) - { - await connection.ExecuteAsync( - $"[{Schema}].[U2f_DeleteByUserId]", - new { UserId = userId }, - commandType: CommandType.StoredProcedure); - } - } - - public override Task ReplaceAsync(U2f obj) - { - throw new NotSupportedException(); - } - - public override Task UpsertAsync(U2f obj) - { - throw new NotSupportedException(); - } - - public override Task DeleteAsync(U2f obj) - { - throw new NotSupportedException(); - } - } -} diff --git a/src/Infrastructure.EntityFramework/EntityFrameworkServiceCollectionExtensions.cs b/src/Infrastructure.EntityFramework/EntityFrameworkServiceCollectionExtensions.cs index f8552ad2ca..54199b2e78 100644 --- a/src/Infrastructure.EntityFramework/EntityFrameworkServiceCollectionExtensions.cs +++ b/src/Infrastructure.EntityFramework/EntityFrameworkServiceCollectionExtensions.cs @@ -50,7 +50,6 @@ namespace Bit.Infrastructure.EntityFramework services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/src/Infrastructure.EntityFramework/Models/U2f.cs b/src/Infrastructure.EntityFramework/Models/U2f.cs deleted file mode 100644 index fea13b3b93..0000000000 --- a/src/Infrastructure.EntityFramework/Models/U2f.cs +++ /dev/null @@ -1,17 +0,0 @@ -using AutoMapper; - -namespace Bit.Infrastructure.EntityFramework.Models -{ - public class U2f : Core.Entities.U2f - { - public virtual User User { get; set; } - } - - public class U2fMapperProfile : Profile - { - public U2fMapperProfile() - { - CreateMap().ReverseMap(); - } - } -} diff --git a/src/Infrastructure.EntityFramework/Models/User.cs b/src/Infrastructure.EntityFramework/Models/User.cs index cf9834260c..80a579c9be 100644 --- a/src/Infrastructure.EntityFramework/Models/User.cs +++ b/src/Infrastructure.EntityFramework/Models/User.cs @@ -12,7 +12,6 @@ namespace Bit.Infrastructure.EntityFramework.Models public virtual ICollection OrganizationUsers { get; set; } public virtual ICollection SsoUsers { get; set; } public virtual ICollection Transactions { get; set; } - public virtual ICollection U2fs { get; set; } } public class UserMapperProfile : Profile diff --git a/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs b/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs index f0ee73d6ea..f1cca95bc9 100644 --- a/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs +++ b/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs @@ -36,7 +36,6 @@ namespace Bit.Infrastructure.EntityFramework.Repositories public DbSet SsoUsers { get; set; } public DbSet TaxRates { get; set; } public DbSet Transactions { get; set; } - public DbSet U2fs { get; set; } public DbSet Users { get; set; } protected override void OnModelCreating(ModelBuilder builder) @@ -66,7 +65,6 @@ namespace Bit.Infrastructure.EntityFramework.Repositories var eSsoUser = builder.Entity(); var eTaxRate = builder.Entity(); var eTransaction = builder.Entity(); - var eU2f = builder.Entity(); var eUser = builder.Entity(); eCipher.Property(c => c.Id).ValueGeneratedNever(); @@ -128,7 +126,6 @@ namespace Bit.Infrastructure.EntityFramework.Repositories eSsoUser.ToTable(nameof(SsoUser)); eTaxRate.ToTable(nameof(TaxRate)); eTransaction.ToTable(nameof(Transaction)); - eU2f.ToTable(nameof(U2f)); eUser.ToTable(nameof(User)); } } diff --git a/src/Infrastructure.EntityFramework/Repositories/U2fRepository.cs b/src/Infrastructure.EntityFramework/Repositories/U2fRepository.cs deleted file mode 100644 index 112686827a..0000000000 --- a/src/Infrastructure.EntityFramework/Repositories/U2fRepository.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using AutoMapper; -using Bit.Core.Repositories; -using Bit.Infrastructure.EntityFramework.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; - -namespace Bit.Infrastructure.EntityFramework.Repositories -{ - public class U2fRepository : Repository, IU2fRepository - { - public U2fRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper) - : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.U2fs) - { } - - public async Task> GetManyByUserIdAsync(Guid userId) - { - using (var scope = ServiceScopeFactory.CreateScope()) - { - var dbContext = GetDatabaseContext(scope); - var results = await dbContext.U2fs.Where(u => u.UserId == userId).ToListAsync(); - return (ICollection)results; - } - } - - public async Task DeleteManyByUserIdAsync(Guid userId) - { - using (var scope = ServiceScopeFactory.CreateScope()) - { - var dbContext = GetDatabaseContext(scope); - var u2fs = dbContext.U2fs.Where(u => u.UserId == userId); - dbContext.RemoveRange(u2fs); - await dbContext.SaveChangesAsync(); - } - } - - public override Task ReplaceAsync(Core.Entities.U2f obj) - { - throw new NotSupportedException(); - } - - public override Task UpsertAsync(Core.Entities.U2f obj) - { - throw new NotSupportedException(); - } - - public override Task DeleteAsync(Core.Entities.U2f obj) - { - throw new NotSupportedException(); - } - } -} diff --git a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs index 418e7655e3..244bf608e4 100644 --- a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs +++ b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs @@ -335,8 +335,6 @@ namespace Bit.SharedWeb.Utilities CoreHelpers.CustomProviderName(TwoFactorProviderType.YubiKey)) .AddTokenProvider( CoreHelpers.CustomProviderName(TwoFactorProviderType.Duo)) - .AddTokenProvider( - CoreHelpers.CustomProviderName(TwoFactorProviderType.U2f)) .AddTokenProvider( CoreHelpers.CustomProviderName(TwoFactorProviderType.Remember)) .AddTokenProvider>(TokenOptions.DefaultEmailProvider) diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index cf4c16d48a..d94eed746c 100644 --- a/src/Sql/Sql.sqlproj +++ b/src/Sql/Sql.sqlproj @@ -83,7 +83,6 @@ - @@ -103,7 +102,6 @@ - @@ -164,9 +162,6 @@ - - - @@ -271,7 +266,6 @@ - diff --git a/src/Sql/dbo/Stored Procedures/U2f_Create.sql b/src/Sql/dbo/Stored Procedures/U2f_Create.sql deleted file mode 100644 index b495f2652e..0000000000 --- a/src/Sql/dbo/Stored Procedures/U2f_Create.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE PROCEDURE [dbo].[U2f_Create] - @Id INT OUTPUT, - @UserId UNIQUEIDENTIFIER, - @KeyHandle VARCHAR(200), - @Challenge VARCHAR(200), - @AppId VARCHAR(50), - @Version VARCHAR(20), - @CreationDate DATETIME2(7) -AS -BEGIN - SET NOCOUNT ON - - INSERT INTO [dbo].[U2f] - ( - [UserId], - [KeyHandle], - [Challenge], - [AppId], - [Version], - [CreationDate] - ) - VALUES - ( - @UserId, - @KeyHandle, - @Challenge, - @AppId, - @Version, - @CreationDate - ) - - SET @Id = (SELECT SCOPE_IDENTITY()) -END diff --git a/src/Sql/dbo/Stored Procedures/U2f_DeleteByUserId.sql b/src/Sql/dbo/Stored Procedures/U2f_DeleteByUserId.sql deleted file mode 100644 index 306207adc1..0000000000 --- a/src/Sql/dbo/Stored Procedures/U2f_DeleteByUserId.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE PROCEDURE [dbo].[U2f_DeleteByUserId] - @UserId UNIQUEIDENTIFIER -AS -BEGIN - SET NOCOUNT ON - - DELETE - FROM - [dbo].[U2f] - WHERE - [UserId] = @UserId -END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/U2f_DeleteOld.sql b/src/Sql/dbo/Stored Procedures/U2f_DeleteOld.sql deleted file mode 100644 index aa8f0c6456..0000000000 --- a/src/Sql/dbo/Stored Procedures/U2f_DeleteOld.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE PROCEDURE [dbo].[U2f_DeleteOld] -AS -BEGIN - SET NOCOUNT ON - - DECLARE @BatchSize INT = 100 - DECLARE @Threshold DATETIME2(7) = DATEADD (day, -7, GETUTCDATE()) - - WHILE @BatchSize > 0 - BEGIN - DELETE TOP(@BatchSize) - FROM - [dbo].[U2f] - WHERE - [CreationDate] IS NULL - OR [CreationDate] < @Threshold - - SET @BatchSize = @@ROWCOUNT - END -END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/U2f_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/U2f_ReadByUserId.sql deleted file mode 100644 index 5f92199fdd..0000000000 --- a/src/Sql/dbo/Stored Procedures/U2f_ReadByUserId.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE PROCEDURE [dbo].[U2f_ReadByUserId] - @UserId UNIQUEIDENTIFIER -AS -BEGIN - SET NOCOUNT ON - - SELECT - * - FROM - [dbo].[U2fView] - WHERE - [UserId] = @UserId -END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/User_DeleteById.sql b/src/Sql/dbo/Stored Procedures/User_DeleteById.sql index a3002995fa..726b7cb58d 100644 --- a/src/Sql/dbo/Stored Procedures/User_DeleteById.sql +++ b/src/Sql/dbo/Stored Procedures/User_DeleteById.sql @@ -72,13 +72,6 @@ BEGIN WHERE [UserId] = @Id - -- Delete U2F logins - DELETE - FROM - [dbo].[U2f] - WHERE - [UserId] = @Id - -- Delete SSO Users DELETE FROM diff --git a/src/Sql/dbo/Tables/U2f.sql b/src/Sql/dbo/Tables/U2f.sql deleted file mode 100644 index 00d23f97a3..0000000000 --- a/src/Sql/dbo/Tables/U2f.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE [dbo].[U2f] ( - [Id] INT IDENTITY (1, 1) NOT NULL, - [UserId] UNIQUEIDENTIFIER NOT NULL, - [KeyHandle] VARCHAR (200) NULL, - [Challenge] VARCHAR (200) NOT NULL, - [AppId] VARCHAR (50) NOT NULL, - [Version] VARCHAR (20) NOT NULL, - [CreationDate] DATETIME2 (7) NOT NULL, - CONSTRAINT [PK_U2f] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_U2f_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) -); - - -GO -CREATE NONCLUSTERED INDEX [IX_U2f_CreationDate] - ON [dbo].[U2f]([CreationDate] ASC) - - -GO -CREATE NONCLUSTERED INDEX [IX_U2f_UserId] - ON [dbo].[U2f]([UserId] ASC); - diff --git a/src/Sql/dbo/Views/U2fView.sql b/src/Sql/dbo/Views/U2fView.sql deleted file mode 100644 index 0827468a44..0000000000 --- a/src/Sql/dbo/Views/U2fView.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE VIEW [dbo].[U2fView] -AS -SELECT - * -FROM - [dbo].[U2f] \ No newline at end of file diff --git a/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs b/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs index ae20563807..aea526704c 100644 --- a/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs +++ b/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs @@ -88,7 +88,6 @@ namespace Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures cfg.AddProfile(); cfg.AddProfile(); cfg.AddProfile(); - cfg.AddProfile(); cfg.AddProfile(); }) .CreateMapper())); diff --git a/test/Core.Test/AutoFixture/U2fFixtures.cs b/test/Core.Test/AutoFixture/U2fFixtures.cs deleted file mode 100644 index 6100c61ed8..0000000000 --- a/test/Core.Test/AutoFixture/U2fFixtures.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using AutoFixture; -using AutoFixture.Kernel; -using Bit.Core.Entities; -using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; -using Bit.Core.Test.AutoFixture.Relays; -using Bit.Core.Test.AutoFixture.UserFixtures; -using Bit.Infrastructure.EntityFramework.Repositories; -using Bit.Test.Common.AutoFixture; -using Bit.Test.Common.AutoFixture.Attributes; - -namespace Bit.Core.Test.AutoFixture.U2fFixtures -{ - internal class U2fBuilder : ISpecimenBuilder - { - public object Create(object request, ISpecimenContext context) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var type = request as Type; - if (type == null || type != typeof(U2f)) - { - return new NoSpecimen(); - } - - var fixture = new Fixture(); - fixture.Customizations.Add(new MaxLengthStringRelay()); - var obj = fixture.WithAutoNSubstitutions().Create(); - return obj; - } - } - - internal class EfU2f : ICustomization - { - public void Customize(IFixture fixture) - { - fixture.Customizations.Add(new IgnoreVirtualMembersCustomization()); - fixture.Customizations.Add(new GlobalSettingsBuilder()); - fixture.Customizations.Add(new U2fBuilder()); - fixture.Customizations.Add(new UserBuilder()); - fixture.Customizations.Add(new EfRepositoryListBuilder()); - fixture.Customizations.Add(new EfRepositoryListBuilder()); - } - } - - internal class EfU2fAutoDataAttribute : CustomAutoDataAttribute - { - public EfU2fAutoDataAttribute() : base(new SutProviderCustomization(), new EfU2f()) - { } - } - - internal class InlineEfU2fAutoDataAttribute : InlineCustomAutoDataAttribute - { - public InlineEfU2fAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization), - typeof(EfU2f) }, values) - { } - } -} - diff --git a/test/Core.Test/Identity/U2fTokenProviderTests.cs b/test/Core.Test/Identity/U2fTokenProviderTests.cs deleted file mode 100644 index 7ce603bb18..0000000000 --- a/test/Core.Test/Identity/U2fTokenProviderTests.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Bit.Core.Entities; -using Bit.Core.Enums; -using Bit.Core.Identity; -using Bit.Test.Common.AutoFixture; -using Bit.Test.Common.AutoFixture.Attributes; -using NSubstitute; -using Xunit; - -namespace Bit.Core.Test.Identity -{ - public class U2fTokenProviderTests : BaseTokenProviderTests - { - public override TwoFactorProviderType TwoFactorProviderType => TwoFactorProviderType.U2f; - - public static IEnumerable CanGenerateTwoFactorTokenAsyncData() - { - return new[] - { - new object[] - { - new Dictionary - { - ["Something"] = "Hello" - }, - true, // canAccessPremium - true, // expectedResponse - }, - new object[] - { - new Dictionary(), - true, // canAccessPremium - false, // expectedResponse - }, - new object[] - { - new Dictionary - { - ["Key"] = "Value" - }, - false, // canAccessPremium - false, // expectedResponse - }, - }; - } - - [Theory, BitMemberAutoData(nameof(CanGenerateTwoFactorTokenAsyncData))] - public async Task CanGenerateTwoFactorTokenAsync_Success(Dictionary metaData, bool canAccessPremium, - bool expectedResponse, User user, SutProvider sutProvider) - { - var userManager = SubstituteUserManager(); - MockDatabase(user, metaData); - AdditionalSetup(sutProvider, user) - .CanAccessPremium(user) - .Returns(canAccessPremium); - - var response = await sutProvider.Sut.CanGenerateTwoFactorTokenAsync(userManager, user); - Assert.Equal(expectedResponse, response); - } - } -} diff --git a/test/Core.Test/Repositories/EntityFramework/EqualityComparers/U2fCompare.cs b/test/Core.Test/Repositories/EntityFramework/EqualityComparers/U2fCompare.cs deleted file mode 100644 index 7736c70aa3..0000000000 --- a/test/Core.Test/Repositories/EntityFramework/EqualityComparers/U2fCompare.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Bit.Core.Entities; - -namespace Bit.Core.Test.Repositories.EntityFramework.EqualityComparers -{ - public class U2fCompare : IEqualityComparer - { - public bool Equals(U2f x, U2f y) - { - return x.KeyHandle == y.KeyHandle && - x.Challenge == y.Challenge && - x.AppId == y.AppId && - x.Version == y.Version; - } - - public int GetHashCode([DisallowNull] U2f obj) - { - return base.GetHashCode(); - } - } -} diff --git a/test/Core.Test/Repositories/EntityFramework/U2fRepositoryTests.cs b/test/Core.Test/Repositories/EntityFramework/U2fRepositoryTests.cs deleted file mode 100644 index cd15ae5a19..0000000000 --- a/test/Core.Test/Repositories/EntityFramework/U2fRepositoryTests.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Bit.Core.Entities; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.U2fFixtures; -using Bit.Core.Test.Repositories.EntityFramework.EqualityComparers; -using Xunit; -using EfRepo = Bit.Infrastructure.EntityFramework.Repositories; -using SqlRepo = Bit.Infrastructure.Dapper.Repositories; - -namespace Bit.Core.Test.Repositories.EntityFramework -{ - public class U2fRepositoryTests - { - - [CiSkippedTheory, EfU2fAutoData] - public async void CreateAsync_Works_DataMatches( - U2f u2f, - User user, - U2fCompare equalityComparer, - List suts, - List efUserRepos, - SqlRepo.U2fRepository sqlU2fRepo, - SqlRepo.UserRepository sqlUserRepo - ) - { - var savedU2fs = new List(); - foreach (var sut in suts) - { - var i = suts.IndexOf(sut); - - var efUser = await efUserRepos[i].CreateAsync(user); - sut.ClearChangeTracking(); - - u2f.UserId = efUser.Id; - var postEfU2f = await sut.CreateAsync(u2f); - sut.ClearChangeTracking(); - - var savedU2f = await sut.GetByIdAsync(postEfU2f.Id); - savedU2fs.Add(savedU2f); - } - - var sqlUser = await sqlUserRepo.CreateAsync(user); - - u2f.UserId = sqlUser.Id; - var sqlU2f = await sqlU2fRepo.CreateAsync(u2f); - var savedSqlU2f = await sqlU2fRepo.GetByIdAsync(sqlU2f.Id); - savedU2fs.Add(savedSqlU2f); - - var distinctItems = savedU2fs.Distinct(equalityComparer); - Assert.True(!distinctItems.Skip(1).Any()); - } - } -} diff --git a/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs b/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs index 64ab3b8345..988f17e855 100644 --- a/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs +++ b/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Text; using System.Threading.Tasks; using AutoFixture; using Bit.Core.Entities; @@ -11,7 +12,6 @@ using Bit.Core.Test.AutoFixture.CipherFixtures; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; -using U2F.Core.Utils; using Xunit; namespace Bit.Core.Test.Services @@ -35,7 +35,8 @@ namespace Bit.Core.Test.Services { var sutProvider = GetSutProvider(tempDirectory); - await sutProvider.Sut.UploadNewAttachmentAsync(new MemoryStream(stream.GetBytes()), cipher, attachmentData); + await sutProvider.Sut.UploadNewAttachmentAsync(new MemoryStream(Encoding.UTF8.GetBytes(stream)), + cipher, attachmentData); AssertFileCreation($"{tempDirectory}/{cipher.Id}/{attachmentData.AttachmentId}", stream); } @@ -51,8 +52,8 @@ namespace Bit.Core.Test.Services { var sutProvider = GetSutProvider(tempDirectory); - await sutProvider.Sut.UploadShareAttachmentAsync(new MemoryStream(stream.GetBytes()), cipher.Id, - cipher.OrganizationId.Value, attachmentData); + await sutProvider.Sut.UploadShareAttachmentAsync(new MemoryStream(Encoding.UTF8.GetBytes(stream)), + cipher.Id, cipher.OrganizationId.Value, attachmentData); AssertFileCreation($"{tempDirectory}/temp/{cipher.Id}/{cipher.OrganizationId}/{attachmentData.AttachmentId}", stream); } diff --git a/util/Migrator/DbScripts/2020-09-09_00-ScriptMigrateU2FToWebAuthn.cs b/util/Migrator/DbScripts/2020-09-09_00-ScriptMigrateU2FToWebAuthn.cs deleted file mode 100644 index 5990665873..0000000000 --- a/util/Migrator/DbScripts/2020-09-09_00-ScriptMigrateU2FToWebAuthn.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using Bit.Core.Enums; -using Bit.Core.Models; -using DbUp.Engine; -using Newtonsoft.Json; - -namespace Bit.Migrator.DbScripts -{ - class ScriptMigrateU2FToWebAuthn : IScript - { - - public string ProvideScript(Func commandFactory) - { - var cmd = commandFactory(); - cmd.CommandText = "SELECT Id, TwoFactorProviders FROM [dbo].[User] WHERE TwoFactorProviders IS NOT NULL"; - - var users = new List(); - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetGuid(0); - var twoFactorProviders = reader.GetString(1); - - if (string.IsNullOrWhiteSpace(twoFactorProviders)) - { - continue; - } - - var providers = JsonConvert.DeserializeObject>(twoFactorProviders); - - if (!providers.ContainsKey(TwoFactorProviderType.U2f)) - { - continue; - } - - var u2fProvider = providers[TwoFactorProviderType.U2f]; - - if (!u2fProvider.Enabled || !HasProperMetaData(u2fProvider)) - { - continue; - } - - var u2fKeys = LoadKeys(u2fProvider); - var webAuthnKeys = u2fKeys.Select(key => (key.Item1, key.Item2.ToWebAuthnData())); - - var webAuthnProvider = new TwoFactorProvider - { - Enabled = true, - MetaData = webAuthnKeys.ToDictionary(x => x.Item1, x => (object)x.Item2) - }; - - providers[TwoFactorProviderType.WebAuthn] = webAuthnProvider; - - users.Add(new User - { - Id = id, - TwoFactorProviders = JsonConvert.SerializeObject(providers), - }); - } - } - - foreach (User user in users) - { - var command = commandFactory(); - - command.CommandText = "UPDATE [dbo].[User] SET TwoFactorProviders = @twoFactorProviders WHERE Id = @id"; - var idParameter = command.CreateParameter(); - idParameter.ParameterName = "@id"; - idParameter.Value = user.Id; - - var twoFactorParameter = command.CreateParameter(); - twoFactorParameter.ParameterName = "@twoFactorProviders"; - twoFactorParameter.Value = user.TwoFactorProviders; - - command.Parameters.Add(idParameter); - command.Parameters.Add(twoFactorParameter); - - command.ExecuteNonQuery(); - } - - return ""; - } - - private bool HasProperMetaData(TwoFactorProvider provider) - { - return (provider?.MetaData?.Count ?? 0) > 0; - } - - private List> LoadKeys(TwoFactorProvider provider) - { - var keys = new List>(); - - // Support up to 5 keys - for (var i = 1; i <= 5; i++) - { - var keyName = $"Key{i}"; - if (provider.MetaData.ContainsKey(keyName)) - { - var key = new TwoFactorProvider.U2fMetaData((dynamic)provider.MetaData[keyName]); - if (!key?.Compromised ?? false) - { - keys.Add(new Tuple(keyName, key)); - } - } - } - - return keys; - } - - private class User - { - public Guid Id { get; set; } - public string TwoFactorProviders { get; set; } - } - } -} diff --git a/util/Migrator/DbScripts/2022-01-21_00_RemoveU2F.sql b/util/Migrator/DbScripts/2022-01-21_00_RemoveU2F.sql new file mode 100644 index 0000000000..92a9ec9870 --- /dev/null +++ b/util/Migrator/DbScripts/2022-01-21_00_RemoveU2F.sql @@ -0,0 +1,154 @@ +IF OBJECT_ID('[dbo].[U2f_Create]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[U2f_Create] +END +GO + +IF OBJECT_ID('[dbo].[U2f_DeleteByUserId]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[U2f_DeleteByUserId] +END +GO + +IF OBJECT_ID('[dbo].[U2f_DeleteOld]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[U2f_DeleteOld] +END +GO + +IF OBJECT_ID('[dbo].[U2f_ReadByUserId]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[U2f_ReadByUserId] +END +GO + +IF OBJECT_ID('[dbo].[U2f_ReadById]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[U2f_ReadById] +END +GO + +IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'U2fView') +BEGIN + DROP VIEW [dbo].[U2fView]; +END +GO + +IF OBJECT_ID('[dbo].[U2f]') IS NOT NULL +BEGIN + DROP TABLE [dbo].[U2f] +END +GO + +IF OBJECT_ID('[dbo].[User_DeleteById]') IS NOT NULL + BEGIN + DROP PROCEDURE [dbo].[User_DeleteById] + END +GO + +CREATE PROCEDURE [dbo].[User_DeleteById] +@Id UNIQUEIDENTIFIER + WITH RECOMPILE +AS +BEGIN + SET NOCOUNT ON + DECLARE @BatchSize INT = 100 + + -- Delete ciphers + WHILE @BatchSize > 0 + BEGIN + BEGIN TRANSACTION User_DeleteById_Ciphers + + DELETE TOP(@BatchSize) + FROM + [dbo].[Cipher] + WHERE + [UserId] = @Id + + SET @BatchSize = @@ROWCOUNT + + COMMIT TRANSACTION User_DeleteById_Ciphers + END + + BEGIN TRANSACTION User_DeleteById + + -- Delete folders + DELETE + FROM + [dbo].[Folder] + WHERE + [UserId] = @Id + + -- Delete devices + DELETE + FROM + [dbo].[Device] + WHERE + [UserId] = @Id + + -- Delete collection users + DELETE + CU + FROM + [dbo].[CollectionUser] CU + INNER JOIN + [dbo].[OrganizationUser] OU ON OU.[Id] = CU.[OrganizationUserId] + WHERE + OU.[UserId] = @Id + + -- Delete group users + DELETE + GU + FROM + [dbo].[GroupUser] GU + INNER JOIN + [dbo].[OrganizationUser] OU ON OU.[Id] = GU.[OrganizationUserId] + WHERE + OU.[UserId] = @Id + + -- Delete organization users + DELETE + FROM + [dbo].[OrganizationUser] + WHERE + [UserId] = @Id + + -- Delete provider users + DELETE + FROM + [dbo].[ProviderUser] + WHERE + [UserId] = @Id + + -- Delete SSO Users + DELETE + FROM + [dbo].[SsoUser] + WHERE + [UserId] = @Id + + -- Delete Emergency Accesses + DELETE + FROM + [dbo].[EmergencyAccess] + WHERE + [GrantorId] = @Id + OR + [GranteeId] = @Id + + -- Delete Sends + DELETE + FROM + [dbo].[Send] + WHERE + [UserId] = @Id + + -- Finally, delete the user + DELETE + FROM + [dbo].[User] + WHERE + [Id] = @Id + + COMMIT TRANSACTION User_DeleteById +END diff --git a/util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.Designer.cs b/util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.Designer.cs new file mode 100644 index 0000000000..e928bf25fd --- /dev/null +++ b/util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.Designer.cs @@ -0,0 +1,1522 @@ +// +using System; +using Bit.Infrastructure.EntityFramework.Repositories; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Bit.MySqlMigrations.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20220121092546_RemoveU2F")] + partial class RemoveU2F + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.12"); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("Attachments") + .HasColumnType("longtext"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("DeletedDate") + .HasColumnType("datetime(6)"); + + b.Property("Favorites") + .HasColumnType("longtext"); + + b.Property("Folders") + .HasColumnType("longtext"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("Reprompt") + .HasColumnType("tinyint unsigned"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("Cipher"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExternalId") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("Collection"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => + { + b.Property("CollectionId") + .HasColumnType("char(36)"); + + b.Property("CipherId") + .HasColumnType("char(36)"); + + b.HasKey("CollectionId", "CipherId"); + + b.HasIndex("CipherId"); + + b.ToTable("CollectionCipher"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => + { + b.Property("CollectionId") + .HasColumnType("char(36)"); + + b.Property("GroupId") + .HasColumnType("char(36)"); + + b.Property("HidePasswords") + .HasColumnType("tinyint(1)"); + + b.Property("ReadOnly") + .HasColumnType("tinyint(1)"); + + b.HasKey("CollectionId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("CollectionGroups"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => + { + b.Property("CollectionId") + .HasColumnType("char(36)"); + + b.Property("OrganizationUserId") + .HasColumnType("char(36)"); + + b.Property("HidePasswords") + .HasColumnType("tinyint(1)"); + + b.Property("ReadOnly") + .HasColumnType("tinyint(1)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("CollectionId", "OrganizationUserId"); + + b.HasIndex("OrganizationUserId"); + + b.HasIndex("UserId"); + + b.ToTable("CollectionUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Identifier") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PushToken") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Device"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("GranteeId") + .HasColumnType("char(36)"); + + b.Property("GrantorId") + .HasColumnType("char(36)"); + + b.Property("KeyEncrypted") + .HasColumnType("longtext"); + + b.Property("LastNotificationDate") + .HasColumnType("datetime(6)"); + + b.Property("RecoveryInitiatedDate") + .HasColumnType("datetime(6)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("WaitTimeDays") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GranteeId"); + + b.HasIndex("GrantorId"); + + b.ToTable("EmergencyAccess"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Event", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ActingUserId") + .HasColumnType("char(36)"); + + b.Property("CipherId") + .HasColumnType("char(36)"); + + b.Property("CollectionId") + .HasColumnType("char(36)"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DeviceType") + .HasColumnType("tinyint unsigned"); + + b.Property("GroupId") + .HasColumnType("char(36)"); + + b.Property("IpAddress") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("OrganizationUserId") + .HasColumnType("char(36)"); + + b.Property("PolicyId") + .HasColumnType("char(36)"); + + b.Property("ProviderId") + .HasColumnType("char(36)"); + + b.Property("ProviderOrganizationId") + .HasColumnType("char(36)"); + + b.Property("ProviderUserId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Event"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Folder"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Grant", b => + { + b.Property("Key") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ClientId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ConsumedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("Description") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("SessionId") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SubjectId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Key"); + + b.ToTable("Grant"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("AccessAll") + .HasColumnType("tinyint(1)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExternalId") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("Group"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => + { + b.Property("GroupId") + .HasColumnType("char(36)"); + + b.Property("OrganizationUserId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("GroupId", "OrganizationUserId"); + + b.HasIndex("OrganizationUserId"); + + b.HasIndex("UserId"); + + b.ToTable("GroupUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Installation", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.HasKey("Id"); + + b.ToTable("Installation"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("ApiKey") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("BillingEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("BusinessAddress1") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("BusinessAddress2") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("BusinessAddress3") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("BusinessCountry") + .HasMaxLength(2) + .HasColumnType("varchar(2)"); + + b.Property("BusinessName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("BusinessTaxNumber") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("Gateway") + .HasColumnType("tinyint unsigned"); + + b.Property("GatewayCustomerId") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("GatewaySubscriptionId") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Identifier") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("LicenseKey") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("MaxAutoscaleSeats") + .HasColumnType("int"); + + b.Property("MaxCollections") + .HasColumnType("smallint"); + + b.Property("MaxStorageGb") + .HasColumnType("smallint"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("OwnersNotifiedOfAutoscaling") + .HasColumnType("datetime(6)"); + + b.Property("Plan") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PlanType") + .HasColumnType("tinyint unsigned"); + + b.Property("PrivateKey") + .HasColumnType("longtext"); + + b.Property("PublicKey") + .HasColumnType("longtext"); + + b.Property("ReferenceData") + .HasColumnType("longtext"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Seats") + .HasColumnType("int"); + + b.Property("SelfHost") + .HasColumnType("tinyint(1)"); + + b.Property("Storage") + .HasColumnType("bigint"); + + b.Property("TwoFactorProviders") + .HasColumnType("longtext"); + + b.Property("Use2fa") + .HasColumnType("tinyint(1)"); + + b.Property("UseApi") + .HasColumnType("tinyint(1)"); + + b.Property("UseDirectory") + .HasColumnType("tinyint(1)"); + + b.Property("UseEvents") + .HasColumnType("tinyint(1)"); + + b.Property("UseGroups") + .HasColumnType("tinyint(1)"); + + b.Property("UseKeyConnector") + .HasColumnType("tinyint(1)"); + + b.Property("UsePolicies") + .HasColumnType("tinyint(1)"); + + b.Property("UseResetPassword") + .HasColumnType("tinyint(1)"); + + b.Property("UseSso") + .HasColumnType("tinyint(1)"); + + b.Property("UseTotp") + .HasColumnType("tinyint(1)"); + + b.Property("UsersGetPremium") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CloudSponsor") + .HasColumnType("tinyint(1)"); + + b.Property("FriendlyName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("InstallationId") + .HasColumnType("char(36)"); + + b.Property("LastSyncDate") + .HasColumnType("datetime(6)"); + + b.Property("OfferedToEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PlanSponsorshipType") + .HasColumnType("tinyint unsigned"); + + b.Property("SponsoredOrganizationId") + .HasColumnType("char(36)"); + + b.Property("SponsoringOrganizationId") + .HasColumnType("char(36)"); + + b.Property("SponsoringOrganizationUserId") + .HasColumnType("char(36)"); + + b.Property("SponsorshipLapsedDate") + .HasColumnType("datetime(6)"); + + b.Property("TimesRenewedWithoutValidation") + .HasColumnType("tinyint unsigned"); + + b.HasKey("Id"); + + b.HasIndex("InstallationId"); + + b.HasIndex("SponsoredOrganizationId"); + + b.HasIndex("SponsoringOrganizationId"); + + b.ToTable("OrganizationSponsorship"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("AccessAll") + .HasColumnType("tinyint(1)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExternalId") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Key") + .HasColumnType("longtext"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("Permissions") + .HasColumnType("longtext"); + + b.Property("ResetPasswordKey") + .HasColumnType("longtext"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("OrganizationUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("Policy"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Provider", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("BillingEmail") + .HasColumnType("longtext"); + + b.Property("BusinessAddress1") + .HasColumnType("longtext"); + + b.Property("BusinessAddress2") + .HasColumnType("longtext"); + + b.Property("BusinessAddress3") + .HasColumnType("longtext"); + + b.Property("BusinessCountry") + .HasColumnType("longtext"); + + b.Property("BusinessName") + .HasColumnType("longtext"); + + b.Property("BusinessTaxNumber") + .HasColumnType("longtext"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("UseEvents") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("Provider"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Key") + .HasColumnType("longtext"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("ProviderId") + .HasColumnType("char(36)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Settings") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("ProviderId"); + + b.ToTable("ProviderOrganization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Email") + .HasColumnType("longtext"); + + b.Property("Key") + .HasColumnType("longtext"); + + b.Property("Permissions") + .HasColumnType("longtext"); + + b.Property("ProviderId") + .HasColumnType("char(36)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProviderId"); + + b.HasIndex("UserId"); + + b.ToTable("ProviderUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("AccessCount") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("DeletionDate") + .HasColumnType("datetime(6)"); + + b.Property("Disabled") + .HasColumnType("tinyint(1)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("HideEmail") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .HasColumnType("longtext"); + + b.Property("MaxAccessCount") + .HasColumnType("int"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("Password") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("Send"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("SsoConfig"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExternalId") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("SsoUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.TaxRate", b => + { + b.Property("Id") + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("Active") + .HasColumnType("tinyint(1)"); + + b.Property("Country") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PostalCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("Rate") + .HasColumnType("decimal(65,30)"); + + b.Property("State") + .HasMaxLength(2) + .HasColumnType("varchar(2)"); + + b.HasKey("Id"); + + b.ToTable("TaxRate"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Details") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Gateway") + .HasColumnType("tinyint unsigned"); + + b.Property("GatewayId") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("PaymentMethodType") + .HasColumnType("tinyint unsigned"); + + b.Property("Refunded") + .HasColumnType("tinyint(1)"); + + b.Property("RefundedAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("Type") + .HasColumnType("tinyint unsigned"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("Transaction"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => + { + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("AccountRevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("ApiKey") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreationDate") + .HasColumnType("datetime(6)"); + + b.Property("Culture") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailVerified") + .HasColumnType("tinyint(1)"); + + b.Property("EquivalentDomains") + .HasColumnType("longtext"); + + b.Property("ExcludedGlobalEquivalentDomains") + .HasColumnType("longtext"); + + b.Property("ForcePasswordReset") + .HasColumnType("tinyint(1)"); + + b.Property("Gateway") + .HasColumnType("tinyint unsigned"); + + b.Property("GatewayCustomerId") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("GatewaySubscriptionId") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Kdf") + .HasColumnType("tinyint unsigned"); + + b.Property("KdfIterations") + .HasColumnType("int"); + + b.Property("Key") + .HasColumnType("longtext"); + + b.Property("LicenseKey") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("MasterPassword") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("MasterPasswordHint") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("MaxStorageGb") + .HasColumnType("smallint"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Premium") + .HasColumnType("tinyint(1)"); + + b.Property("PremiumExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("PrivateKey") + .HasColumnType("longtext"); + + b.Property("PublicKey") + .HasColumnType("longtext"); + + b.Property("ReferenceData") + .HasColumnType("longtext"); + + b.Property("RenewalReminderDate") + .HasColumnType("datetime(6)"); + + b.Property("RevisionDate") + .HasColumnType("datetime(6)"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Storage") + .HasColumnType("bigint"); + + b.Property("TwoFactorProviders") + .HasColumnType("longtext"); + + b.Property("TwoFactorRecoveryCode") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("UsesKeyConnector") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Ciphers") + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("Ciphers") + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Cipher", "Cipher") + .WithMany("CollectionCiphers") + .HasForeignKey("CipherId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") + .WithMany("CollectionCiphers") + .HasForeignKey("CollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cipher"); + + b.Navigation("Collection"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") + .WithMany("CollectionGroups") + .HasForeignKey("CollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Collection"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") + .WithMany("CollectionUsers") + .HasForeignKey("CollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") + .WithMany("CollectionUsers") + .HasForeignKey("OrganizationUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) + .WithMany("CollectionUsers") + .HasForeignKey("UserId"); + + b.Navigation("Collection"); + + b.Navigation("OrganizationUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantee") + .WithMany() + .HasForeignKey("GranteeId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantor") + .WithMany() + .HasForeignKey("GrantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Grantee"); + + b.Navigation("Grantor"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("Folders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Groups") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") + .WithMany("GroupUsers") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") + .WithMany() + .HasForeignKey("OrganizationUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) + .WithMany("GroupUsers") + .HasForeignKey("UserId"); + + b.Navigation("Group"); + + b.Navigation("OrganizationUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoredOrganization") + .WithMany() + .HasForeignKey("SponsoredOrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoringOrganization") + .WithMany() + .HasForeignKey("SponsoringOrganizationId"); + + b.Navigation("Installation"); + + b.Navigation("SponsoredOrganization"); + + b.Navigation("SponsoringOrganization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("OrganizationUsers") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("OrganizationUsers") + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Policies") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Provider"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("SsoConfigs") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("SsoUsers") + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("SsoUsers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Transactions") + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("Transactions") + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => + { + b.Navigation("CollectionCiphers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => + { + b.Navigation("CollectionCiphers"); + + b.Navigation("CollectionGroups"); + + b.Navigation("CollectionUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => + { + b.Navigation("GroupUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => + { + b.Navigation("Ciphers"); + + b.Navigation("Groups"); + + b.Navigation("OrganizationUsers"); + + b.Navigation("Policies"); + + b.Navigation("SsoConfigs"); + + b.Navigation("SsoUsers"); + + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => + { + b.Navigation("CollectionUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => + { + b.Navigation("Ciphers"); + + b.Navigation("CollectionUsers"); + + b.Navigation("Folders"); + + b.Navigation("GroupUsers"); + + b.Navigation("OrganizationUsers"); + + b.Navigation("SsoUsers"); + + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.cs b/util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.cs new file mode 100644 index 0000000000..e937b332c4 --- /dev/null +++ b/util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Bit.MySqlMigrations.Migrations +{ + public partial class RemoveU2F : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "U2f"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "U2f", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + AppId = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Challenge = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationDate = table.Column(type: "datetime(6)", nullable: false), + KeyHandle = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Version = table.Column(type: "varchar(20)", maxLength: 20, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_U2f", x => x.Id); + table.ForeignKey( + name: "FK_U2f_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_U2f_UserId", + table: "U2f", + column: "UserId"); + } + } +} diff --git a/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs b/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs index 59a77919d8..48f380fe5a 100644 --- a/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs +++ b/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs @@ -15,9 +15,9 @@ namespace Bit.MySqlMigrations.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Relational:MaxIdentifierLength", 64) - .HasAnnotation("ProductVersion", "5.0.9"); + .HasAnnotation("ProductVersion", "5.0.12"); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Cipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -64,7 +64,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Cipher"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Collection", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -92,7 +92,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Collection"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionCipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => { b.Property("CollectionId") .HasColumnType("char(36)"); @@ -107,7 +107,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("CollectionCipher"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionGroup", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => { b.Property("CollectionId") .HasColumnType("char(36)"); @@ -128,7 +128,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("CollectionGroups"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => { b.Property("CollectionId") .HasColumnType("char(36)"); @@ -154,7 +154,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("CollectionUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Device", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -191,7 +191,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Device"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.EmergencyAccess", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -239,7 +239,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("EmergencyAccess"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Event", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Event", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -295,7 +295,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Event"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Folder", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -319,7 +319,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Folder"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Grant", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Grant", b => { b.Property("Key") .HasMaxLength(200) @@ -362,7 +362,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Grant"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Group", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -394,7 +394,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Group"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.GroupUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => { b.Property("GroupId") .HasColumnType("char(36)"); @@ -414,7 +414,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("GroupUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Installation", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Installation", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -438,7 +438,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Installation"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Organization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -588,7 +588,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationSponsorship", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -639,7 +639,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("OrganizationSponsorship"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -691,7 +691,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("OrganizationUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Policy", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -721,7 +721,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Policy"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.Provider", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Provider", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -770,7 +770,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Provider"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderOrganization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -802,7 +802,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("ProviderOrganization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -843,7 +843,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("ProviderUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Send", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -900,7 +900,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Send"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoConfig", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -928,7 +928,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("SsoConfig"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -956,7 +956,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("SsoUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.TaxRate", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.TaxRate", b => { b.Property("Id") .HasMaxLength(40) @@ -985,7 +985,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("TaxRate"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Transaction", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -1034,42 +1034,7 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("Transaction"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.U2f", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AppId") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Challenge") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("KeyHandle") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("UserId") - .HasColumnType("char(36)"); - - b.Property("Version") - .HasMaxLength(20) - .HasColumnType("varchar(20)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("U2f"); - }); - - modelBuilder.Entity("Bit.Core.Models.EntityFramework.User", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => { b.Property("Id") .HasColumnType("char(36)"); @@ -1189,13 +1154,13 @@ namespace Bit.MySqlMigrations.Migrations b.ToTable("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Cipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Ciphers") .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("Ciphers") .HasForeignKey("UserId"); @@ -1204,9 +1169,9 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Collection", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany() .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1215,15 +1180,15 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionCipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Cipher", "Cipher") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Cipher", "Cipher") .WithMany("CollectionCiphers") .HasForeignKey("CipherId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.Collection", "Collection") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") .WithMany("CollectionCiphers") .HasForeignKey("CollectionId") .OnDelete(DeleteBehavior.Cascade) @@ -1234,15 +1199,15 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Collection"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionGroup", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Collection", "Collection") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") .WithMany("CollectionGroups") .HasForeignKey("CollectionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.Group", "Group") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") .WithMany() .HasForeignKey("GroupId") .OnDelete(DeleteBehavior.Cascade) @@ -1253,21 +1218,21 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Group"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Collection", "Collection") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") .WithMany("CollectionUsers") .HasForeignKey("CollectionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.OrganizationUser", "OrganizationUser") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") .WithMany("CollectionUsers") .HasForeignKey("OrganizationUserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", null) + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) .WithMany("CollectionUsers") .HasForeignKey("UserId"); @@ -1276,9 +1241,9 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("OrganizationUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Device", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => { - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1287,13 +1252,13 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.EmergencyAccess", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => { - b.HasOne("Bit.Core.Models.EntityFramework.User", "Grantee") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantee") .WithMany() .HasForeignKey("GranteeId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "Grantor") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantor") .WithMany() .HasForeignKey("GrantorId") .OnDelete(DeleteBehavior.Cascade) @@ -1304,9 +1269,9 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Grantor"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Folder", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => { - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("Folders") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1315,9 +1280,9 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Group", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Groups") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1326,21 +1291,21 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.GroupUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Group", "Group") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") .WithMany("GroupUsers") .HasForeignKey("GroupId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.OrganizationUser", "OrganizationUser") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") .WithMany() .HasForeignKey("OrganizationUserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", null) + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) .WithMany("GroupUsers") .HasForeignKey("UserId"); @@ -1349,17 +1314,17 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("OrganizationUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationSponsorship", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Installation", "Installation") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Installation", "Installation") .WithMany() .HasForeignKey("InstallationId"); - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "SponsoredOrganization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoredOrganization") .WithMany() .HasForeignKey("SponsoredOrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "SponsoringOrganization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoringOrganization") .WithMany() .HasForeignKey("SponsoringOrganizationId"); @@ -1370,15 +1335,15 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("SponsoringOrganization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("OrganizationUsers") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("OrganizationUsers") .HasForeignKey("UserId"); @@ -1387,9 +1352,9 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Policy", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Policies") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1398,15 +1363,15 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderOrganization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany() .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.Provider.Provider", "Provider") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") .WithMany() .HasForeignKey("ProviderId") .OnDelete(DeleteBehavior.Cascade) @@ -1417,15 +1382,15 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Provider"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Provider.Provider", "Provider") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") .WithMany() .HasForeignKey("ProviderId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany() .HasForeignKey("UserId"); @@ -1434,13 +1399,13 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Send", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany() .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany() .HasForeignKey("UserId"); @@ -1449,9 +1414,9 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoConfig", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("SsoConfigs") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1460,13 +1425,13 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("SsoUsers") .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("SsoUsers") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1477,13 +1442,13 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Transaction", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Transactions") .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("Transactions") .HasForeignKey("UserId"); @@ -1492,23 +1457,12 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.U2f", b => - { - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") - .WithMany("U2fs") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Cipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => { b.Navigation("CollectionCiphers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Collection", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => { b.Navigation("CollectionCiphers"); @@ -1517,12 +1471,12 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("CollectionUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Group", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => { b.Navigation("GroupUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Organization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => { b.Navigation("Ciphers"); @@ -1539,12 +1493,12 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("Transactions"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => { b.Navigation("CollectionUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.User", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => { b.Navigation("Ciphers"); @@ -1559,8 +1513,6 @@ namespace Bit.MySqlMigrations.Migrations b.Navigation("SsoUsers"); b.Navigation("Transactions"); - - b.Navigation("U2fs"); }); #pragma warning restore 612, 618 } diff --git a/util/MySqlMigrations/Scripts/2022-01-21_00_RemoveU2F.sql b/util/MySqlMigrations/Scripts/2022-01-21_00_RemoveU2F.sql new file mode 100644 index 0000000000000000000000000000000000000000..b39b5b7ca075a4b768e51852c7fe3dff3019b292 GIT binary patch literal 332 zcmZXPOAo +using System; +using Bit.Infrastructure.EntityFramework.Repositories; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace Bit.PostgresMigrations.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20220121092321_RemoveU2F")] + partial class RemoveU2F + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:postgresIndetermanisticCollation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("Relational:MaxIdentifierLength", 63) + .HasAnnotation("ProductVersion", "5.0.12") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("Attachments") + .HasColumnType("text"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DeletedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Favorites") + .HasColumnType("text"); + + b.Property("Folders") + .HasColumnType("text"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("Reprompt") + .HasColumnType("smallint"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("Cipher"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExternalId") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("Collection"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => + { + b.Property("CollectionId") + .HasColumnType("uuid"); + + b.Property("CipherId") + .HasColumnType("uuid"); + + b.HasKey("CollectionId", "CipherId"); + + b.HasIndex("CipherId"); + + b.ToTable("CollectionCipher"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => + { + b.Property("CollectionId") + .HasColumnType("uuid"); + + b.Property("GroupId") + .HasColumnType("uuid"); + + b.Property("HidePasswords") + .HasColumnType("boolean"); + + b.Property("ReadOnly") + .HasColumnType("boolean"); + + b.HasKey("CollectionId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("CollectionGroups"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => + { + b.Property("CollectionId") + .HasColumnType("uuid"); + + b.Property("OrganizationUserId") + .HasColumnType("uuid"); + + b.Property("HidePasswords") + .HasColumnType("boolean"); + + b.Property("ReadOnly") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("CollectionId", "OrganizationUserId"); + + b.HasIndex("OrganizationUserId"); + + b.HasIndex("UserId"); + + b.ToTable("CollectionUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Identifier") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("PushToken") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Device"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("GranteeId") + .HasColumnType("uuid"); + + b.Property("GrantorId") + .HasColumnType("uuid"); + + b.Property("KeyEncrypted") + .HasColumnType("text"); + + b.Property("LastNotificationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("RecoveryInitiatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("WaitTimeDays") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GranteeId"); + + b.HasIndex("GrantorId"); + + b.ToTable("EmergencyAccess"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Event", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("ActingUserId") + .HasColumnType("uuid"); + + b.Property("CipherId") + .HasColumnType("uuid"); + + b.Property("CollectionId") + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("DeviceType") + .HasColumnType("smallint"); + + b.Property("GroupId") + .HasColumnType("uuid"); + + b.Property("IpAddress") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("OrganizationUserId") + .HasColumnType("uuid"); + + b.Property("PolicyId") + .HasColumnType("uuid"); + + b.Property("ProviderId") + .HasColumnType("uuid"); + + b.Property("ProviderOrganizationId") + .HasColumnType("uuid"); + + b.Property("ProviderUserId") + .HasColumnType("uuid"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("Event"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Folder"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Grant", b => + { + b.Property("Key") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ClientId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ConsumedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("Description") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SessionId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("SubjectId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Key"); + + b.ToTable("Grant"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("AccessAll") + .HasColumnType("boolean"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExternalId") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("Group"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => + { + b.Property("GroupId") + .HasColumnType("uuid"); + + b.Property("OrganizationUserId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("GroupId", "OrganizationUserId"); + + b.HasIndex("OrganizationUserId"); + + b.HasIndex("UserId"); + + b.ToTable("GroupUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Installation", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("Key") + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.HasKey("Id"); + + b.ToTable("Installation"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("ApiKey") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("BillingEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("BusinessAddress1") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BusinessAddress2") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BusinessAddress3") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BusinessCountry") + .HasMaxLength(2) + .HasColumnType("character varying(2)"); + + b.Property("BusinessName") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BusinessTaxNumber") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Gateway") + .HasColumnType("smallint"); + + b.Property("GatewayCustomerId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("GatewaySubscriptionId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Identifier") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .UseCollation("postgresIndetermanisticCollation"); + + b.Property("LicenseKey") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("MaxAutoscaleSeats") + .HasColumnType("integer"); + + b.Property("MaxCollections") + .HasColumnType("smallint"); + + b.Property("MaxStorageGb") + .HasColumnType("smallint"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OwnersNotifiedOfAutoscaling") + .HasColumnType("timestamp without time zone"); + + b.Property("Plan") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("PlanType") + .HasColumnType("smallint"); + + b.Property("PrivateKey") + .HasColumnType("text"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("ReferenceData") + .HasColumnType("text"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Seats") + .HasColumnType("integer"); + + b.Property("SelfHost") + .HasColumnType("boolean"); + + b.Property("Storage") + .HasColumnType("bigint"); + + b.Property("TwoFactorProviders") + .HasColumnType("text"); + + b.Property("Use2fa") + .HasColumnType("boolean"); + + b.Property("UseApi") + .HasColumnType("boolean"); + + b.Property("UseDirectory") + .HasColumnType("boolean"); + + b.Property("UseEvents") + .HasColumnType("boolean"); + + b.Property("UseGroups") + .HasColumnType("boolean"); + + b.Property("UseKeyConnector") + .HasColumnType("boolean"); + + b.Property("UsePolicies") + .HasColumnType("boolean"); + + b.Property("UseResetPassword") + .HasColumnType("boolean"); + + b.Property("UseSso") + .HasColumnType("boolean"); + + b.Property("UseTotp") + .HasColumnType("boolean"); + + b.Property("UsersGetPremium") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CloudSponsor") + .HasColumnType("boolean"); + + b.Property("FriendlyName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("InstallationId") + .HasColumnType("uuid"); + + b.Property("LastSyncDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OfferedToEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PlanSponsorshipType") + .HasColumnType("smallint"); + + b.Property("SponsoredOrganizationId") + .HasColumnType("uuid"); + + b.Property("SponsoringOrganizationId") + .HasColumnType("uuid"); + + b.Property("SponsoringOrganizationUserId") + .HasColumnType("uuid"); + + b.Property("SponsorshipLapsedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("TimesRenewedWithoutValidation") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("InstallationId"); + + b.HasIndex("SponsoredOrganizationId"); + + b.HasIndex("SponsoringOrganizationId"); + + b.ToTable("OrganizationSponsorship"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("AccessAll") + .HasColumnType("boolean"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("ExternalId") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Key") + .HasColumnType("text"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("Permissions") + .HasColumnType("text"); + + b.Property("ResetPasswordKey") + .HasColumnType("text"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("OrganizationUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("Policy"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Provider", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("BillingEmail") + .HasColumnType("text"); + + b.Property("BusinessAddress1") + .HasColumnType("text"); + + b.Property("BusinessAddress2") + .HasColumnType("text"); + + b.Property("BusinessAddress3") + .HasColumnType("text"); + + b.Property("BusinessCountry") + .HasColumnType("text"); + + b.Property("BusinessName") + .HasColumnType("text"); + + b.Property("BusinessTaxNumber") + .HasColumnType("text"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("UseEvents") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("Provider"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Key") + .HasColumnType("text"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("ProviderId") + .HasColumnType("uuid"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Settings") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("ProviderId"); + + b.ToTable("ProviderOrganization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("Key") + .HasColumnType("text"); + + b.Property("Permissions") + .HasColumnType("text"); + + b.Property("ProviderId") + .HasColumnType("uuid"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProviderId"); + + b.HasIndex("UserId"); + + b.ToTable("ProviderUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("AccessCount") + .HasColumnType("integer"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DeletionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Disabled") + .HasColumnType("boolean"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HideEmail") + .HasColumnType("boolean"); + + b.Property("Key") + .HasColumnType("text"); + + b.Property("MaxAccessCount") + .HasColumnType("integer"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("Password") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("Send"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("SsoConfig"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExternalId") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .UseCollation("postgresIndetermanisticCollation"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("SsoUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.TaxRate", b => + { + b.Property("Id") + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("Country") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("PostalCode") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.Property("State") + .HasMaxLength(2) + .HasColumnType("character varying(2)"); + + b.HasKey("Id"); + + b.ToTable("TaxRate"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Details") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Gateway") + .HasColumnType("smallint"); + + b.Property("GatewayId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OrganizationId") + .HasColumnType("uuid"); + + b.Property("PaymentMethodType") + .HasColumnType("smallint"); + + b.Property("Refunded") + .HasColumnType("boolean"); + + b.Property("RefundedAmount") + .HasColumnType("numeric"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("UserId"); + + b.ToTable("Transaction"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("AccountRevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ApiKey") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CreationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Culture") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .UseCollation("postgresIndetermanisticCollation"); + + b.Property("EmailVerified") + .HasColumnType("boolean"); + + b.Property("EquivalentDomains") + .HasColumnType("text"); + + b.Property("ExcludedGlobalEquivalentDomains") + .HasColumnType("text"); + + b.Property("ForcePasswordReset") + .HasColumnType("boolean"); + + b.Property("Gateway") + .HasColumnType("smallint"); + + b.Property("GatewayCustomerId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("GatewaySubscriptionId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Kdf") + .HasColumnType("smallint"); + + b.Property("KdfIterations") + .HasColumnType("integer"); + + b.Property("Key") + .HasColumnType("text"); + + b.Property("LicenseKey") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("MasterPassword") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("MasterPasswordHint") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("MaxStorageGb") + .HasColumnType("smallint"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Premium") + .HasColumnType("boolean"); + + b.Property("PremiumExpirationDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PrivateKey") + .HasColumnType("text"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("ReferenceData") + .HasColumnType("text"); + + b.Property("RenewalReminderDate") + .HasColumnType("timestamp without time zone"); + + b.Property("RevisionDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Storage") + .HasColumnType("bigint"); + + b.Property("TwoFactorProviders") + .HasColumnType("text"); + + b.Property("TwoFactorRecoveryCode") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("UsesKeyConnector") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Ciphers") + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("Ciphers") + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Cipher", "Cipher") + .WithMany("CollectionCiphers") + .HasForeignKey("CipherId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") + .WithMany("CollectionCiphers") + .HasForeignKey("CollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cipher"); + + b.Navigation("Collection"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") + .WithMany("CollectionGroups") + .HasForeignKey("CollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Collection"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") + .WithMany("CollectionUsers") + .HasForeignKey("CollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") + .WithMany("CollectionUsers") + .HasForeignKey("OrganizationUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) + .WithMany("CollectionUsers") + .HasForeignKey("UserId"); + + b.Navigation("Collection"); + + b.Navigation("OrganizationUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantee") + .WithMany() + .HasForeignKey("GranteeId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantor") + .WithMany() + .HasForeignKey("GrantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Grantee"); + + b.Navigation("Grantor"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("Folders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Groups") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") + .WithMany("GroupUsers") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") + .WithMany() + .HasForeignKey("OrganizationUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) + .WithMany("GroupUsers") + .HasForeignKey("UserId"); + + b.Navigation("Group"); + + b.Navigation("OrganizationUser"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoredOrganization") + .WithMany() + .HasForeignKey("SponsoredOrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoringOrganization") + .WithMany() + .HasForeignKey("SponsoringOrganizationId"); + + b.Navigation("Installation"); + + b.Navigation("SponsoredOrganization"); + + b.Navigation("SponsoringOrganization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("OrganizationUsers") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("OrganizationUsers") + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Policies") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Provider"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("SsoConfigs") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("SsoUsers") + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("SsoUsers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => + { + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") + .WithMany("Transactions") + .HasForeignKey("OrganizationId"); + + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") + .WithMany("Transactions") + .HasForeignKey("UserId"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => + { + b.Navigation("CollectionCiphers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => + { + b.Navigation("CollectionCiphers"); + + b.Navigation("CollectionGroups"); + + b.Navigation("CollectionUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => + { + b.Navigation("GroupUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => + { + b.Navigation("Ciphers"); + + b.Navigation("Groups"); + + b.Navigation("OrganizationUsers"); + + b.Navigation("Policies"); + + b.Navigation("SsoConfigs"); + + b.Navigation("SsoUsers"); + + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => + { + b.Navigation("CollectionUsers"); + }); + + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => + { + b.Navigation("Ciphers"); + + b.Navigation("CollectionUsers"); + + b.Navigation("Folders"); + + b.Navigation("GroupUsers"); + + b.Navigation("OrganizationUsers"); + + b.Navigation("SsoUsers"); + + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.cs b/util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.cs new file mode 100644 index 0000000000..caca2da9c3 --- /dev/null +++ b/util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.cs @@ -0,0 +1,47 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace Bit.PostgresMigrations.Migrations +{ + public partial class RemoveU2F : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "U2f"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "U2f", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AppId = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + Challenge = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + CreationDate = table.Column(type: "timestamp without time zone", nullable: false), + KeyHandle = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + UserId = table.Column(type: "uuid", nullable: false), + Version = table.Column(type: "character varying(20)", maxLength: 20, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_U2f", x => x.Id); + table.ForeignKey( + name: "FK_U2f_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_U2f_UserId", + table: "U2f", + column: "UserId"); + } + } +} diff --git a/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs b/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs index 7e0f0c9ee8..9d978fc1e6 100644 --- a/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs +++ b/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs @@ -17,10 +17,10 @@ namespace Bit.PostgresMigrations.Migrations modelBuilder .HasAnnotation("Npgsql:CollationDefinition:postgresIndetermanisticCollation", "en-u-ks-primary,en-u-ks-primary,icu,False") .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.9") + .HasAnnotation("ProductVersion", "5.0.12") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Cipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => { b.Property("Id") .HasColumnType("uuid"); @@ -67,7 +67,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Cipher"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Collection", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => { b.Property("Id") .HasColumnType("uuid"); @@ -95,7 +95,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Collection"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionCipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => { b.Property("CollectionId") .HasColumnType("uuid"); @@ -110,7 +110,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("CollectionCipher"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionGroup", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => { b.Property("CollectionId") .HasColumnType("uuid"); @@ -131,7 +131,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("CollectionGroups"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => { b.Property("CollectionId") .HasColumnType("uuid"); @@ -157,7 +157,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("CollectionUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Device", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -194,7 +194,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Device"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.EmergencyAccess", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => { b.Property("Id") .HasColumnType("uuid"); @@ -242,7 +242,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("EmergencyAccess"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Event", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Event", b => { b.Property("Id") .HasColumnType("uuid"); @@ -298,7 +298,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Event"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Folder", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => { b.Property("Id") .HasColumnType("uuid"); @@ -322,7 +322,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Folder"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Grant", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Grant", b => { b.Property("Key") .HasMaxLength(200) @@ -365,7 +365,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Grant"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Group", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => { b.Property("Id") .HasColumnType("uuid"); @@ -397,7 +397,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Group"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.GroupUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => { b.Property("GroupId") .HasColumnType("uuid"); @@ -417,7 +417,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("GroupUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Installation", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Installation", b => { b.Property("Id") .HasColumnType("uuid"); @@ -441,7 +441,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Installation"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Organization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => { b.Property("Id") .HasColumnType("uuid"); @@ -592,7 +592,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationSponsorship", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => { b.Property("Id") .HasColumnType("uuid"); @@ -643,7 +643,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("OrganizationSponsorship"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => { b.Property("Id") .HasColumnType("uuid"); @@ -695,7 +695,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("OrganizationUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Policy", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => { b.Property("Id") .HasColumnType("uuid"); @@ -725,7 +725,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Policy"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.Provider", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Provider", b => { b.Property("Id") .HasColumnType("uuid"); @@ -774,7 +774,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Provider"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderOrganization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => { b.Property("Id") .HasColumnType("uuid"); @@ -806,7 +806,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("ProviderOrganization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => { b.Property("Id") .HasColumnType("uuid"); @@ -847,7 +847,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("ProviderUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Send", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") .HasColumnType("uuid"); @@ -904,7 +904,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Send"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoConfig", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -933,7 +933,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("SsoConfig"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -963,7 +963,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("SsoUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.TaxRate", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.TaxRate", b => { b.Property("Id") .HasMaxLength(40) @@ -992,7 +992,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("TaxRate"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Transaction", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => { b.Property("Id") .HasColumnType("uuid"); @@ -1041,43 +1041,7 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("Transaction"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.U2f", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AppId") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Challenge") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("CreationDate") - .HasColumnType("timestamp without time zone"); - - b.Property("KeyHandle") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.Property("Version") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("U2f"); - }); - - modelBuilder.Entity("Bit.Core.Models.EntityFramework.User", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => { b.Property("Id") .HasColumnType("uuid"); @@ -1198,13 +1162,13 @@ namespace Bit.PostgresMigrations.Migrations b.ToTable("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Cipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Ciphers") .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("Ciphers") .HasForeignKey("UserId"); @@ -1213,9 +1177,9 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Collection", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany() .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1224,15 +1188,15 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionCipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionCipher", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Cipher", "Cipher") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Cipher", "Cipher") .WithMany("CollectionCiphers") .HasForeignKey("CipherId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.Collection", "Collection") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") .WithMany("CollectionCiphers") .HasForeignKey("CollectionId") .OnDelete(DeleteBehavior.Cascade) @@ -1243,15 +1207,15 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Collection"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionGroup", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionGroup", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Collection", "Collection") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") .WithMany("CollectionGroups") .HasForeignKey("CollectionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.Group", "Group") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") .WithMany() .HasForeignKey("GroupId") .OnDelete(DeleteBehavior.Cascade) @@ -1262,21 +1226,21 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Group"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.CollectionUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Collection", "Collection") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Collection", "Collection") .WithMany("CollectionUsers") .HasForeignKey("CollectionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.OrganizationUser", "OrganizationUser") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") .WithMany("CollectionUsers") .HasForeignKey("OrganizationUserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", null) + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) .WithMany("CollectionUsers") .HasForeignKey("UserId"); @@ -1285,9 +1249,9 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("OrganizationUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Device", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b => { - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1296,13 +1260,13 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.EmergencyAccess", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.EmergencyAccess", b => { - b.HasOne("Bit.Core.Models.EntityFramework.User", "Grantee") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantee") .WithMany() .HasForeignKey("GranteeId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "Grantor") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "Grantor") .WithMany() .HasForeignKey("GrantorId") .OnDelete(DeleteBehavior.Cascade) @@ -1313,9 +1277,9 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Grantor"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Folder", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Folder", b => { - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("Folders") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1324,9 +1288,9 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Group", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Groups") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1335,21 +1299,21 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.GroupUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Group", "Group") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group") .WithMany("GroupUsers") .HasForeignKey("GroupId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.OrganizationUser", "OrganizationUser") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser") .WithMany() .HasForeignKey("OrganizationUserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", null) + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", null) .WithMany("GroupUsers") .HasForeignKey("UserId"); @@ -1358,17 +1322,17 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("OrganizationUser"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationSponsorship", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationSponsorship", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Installation", "Installation") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Installation", "Installation") .WithMany() .HasForeignKey("InstallationId"); - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "SponsoredOrganization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoredOrganization") .WithMany() .HasForeignKey("SponsoredOrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "SponsoringOrganization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "SponsoringOrganization") .WithMany() .HasForeignKey("SponsoringOrganizationId"); @@ -1379,15 +1343,15 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("SponsoringOrganization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("OrganizationUsers") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("OrganizationUsers") .HasForeignKey("UserId"); @@ -1396,9 +1360,9 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Policy", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Policy", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Policies") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1407,15 +1371,15 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderOrganization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany() .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.Provider.Provider", "Provider") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") .WithMany() .HasForeignKey("ProviderId") .OnDelete(DeleteBehavior.Cascade) @@ -1426,15 +1390,15 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Provider"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Provider.ProviderUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Provider.Provider", "Provider") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Provider", "Provider") .WithMany() .HasForeignKey("ProviderId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany() .HasForeignKey("UserId"); @@ -1443,13 +1407,13 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Send", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany() .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany() .HasForeignKey("UserId"); @@ -1458,9 +1422,9 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoConfig", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("SsoConfigs") .HasForeignKey("OrganizationId") .OnDelete(DeleteBehavior.Cascade) @@ -1469,13 +1433,13 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Organization"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.SsoUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoUser", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("SsoUsers") .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("SsoUsers") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1486,13 +1450,13 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Transaction", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Transaction", b => { - b.HasOne("Bit.Core.Models.EntityFramework.Organization", "Organization") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization") .WithMany("Transactions") .HasForeignKey("OrganizationId"); - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") + b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User") .WithMany("Transactions") .HasForeignKey("UserId"); @@ -1501,23 +1465,12 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.U2f", b => - { - b.HasOne("Bit.Core.Models.EntityFramework.User", "User") - .WithMany("U2fs") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Cipher", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b => { b.Navigation("CollectionCiphers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Collection", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b => { b.Navigation("CollectionCiphers"); @@ -1526,12 +1479,12 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("CollectionUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Group", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Group", b => { b.Navigation("GroupUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.Organization", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Organization", b => { b.Navigation("Ciphers"); @@ -1548,12 +1501,12 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("Transactions"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.OrganizationUser", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", b => { b.Navigation("CollectionUsers"); }); - modelBuilder.Entity("Bit.Core.Models.EntityFramework.User", b => + modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b => { b.Navigation("Ciphers"); @@ -1568,8 +1521,6 @@ namespace Bit.PostgresMigrations.Migrations b.Navigation("SsoUsers"); b.Navigation("Transactions"); - - b.Navigation("U2fs"); }); #pragma warning restore 612, 618 } diff --git a/util/PostgresMigrations/Scripts/2022-01-21_00_RemoveU2F.psql b/util/PostgresMigrations/Scripts/2022-01-21_00_RemoveU2F.psql new file mode 100644 index 0000000000000000000000000000000000000000..7295202df30a4d35722f80da9de8623a27a4a16a GIT binary patch literal 332 zcmZXPK@Y)D5QOLKSBOhVM3gv)6IIcqw5jT~5lS3rqDcICeDCQ^Hg9)lJ3HO^yf;cU zRYGp^68g0^WDgW50!`E)=6s73Th>%Fh4SfJ+G?O9^~VbAwqNTRl(J=bIpJ%emCicp zrk(C|rLL;9q^rOs^B3Hv+T?#`pab)+)r;Yl;D`2XW-7o{t=LkBi!)q=+~?!RC^}r) t=b7x1UFw)Rw0+Lag)V45sm9fU4f8KYBlY0+?3RP}&#Q;C6%pXkOuj|KFZBQb literal 0 HcmV?d00001 diff --git a/util/Setup/AppIdBuilder.cs b/util/Setup/AppIdBuilder.cs index b5392cb1a7..1af775f459 100644 --- a/util/Setup/AppIdBuilder.cs +++ b/util/Setup/AppIdBuilder.cs @@ -19,6 +19,7 @@ namespace Bit.Setup Url = _context.Config.Url }; + // Needed for backwards compatability with migrated U2F tokens. Helpers.WriteLine(_context, "Building FIDO U2F app id."); Directory.CreateDirectory("/bitwarden/web/"); var template = Helpers.ReadTemplate("AppId"); diff --git a/util/Setup/Templates/NginxConfig.hbs b/util/Setup/Templates/NginxConfig.hbs index 7bc964635a..5c395141ec 100644 --- a/util/Setup/Templates/NginxConfig.hbs +++ b/util/Setup/Templates/NginxConfig.hbs @@ -88,10 +88,6 @@ server { proxy_pass http://web:5000/duo-connector.html; } - location = /u2f-connector.html { - proxy_pass http://web:5000/u2f-connector.html; - } - location = /webauthn-connector.html { proxy_pass http://web:5000/webauthn-connector.html; }