mirror of
https://github.com/bitwarden/server.git
synced 2025-02-22 02:51:33 +01:00
Remove the u2f lib (#1820)
This commit is contained in:
parent
5268f2781e
commit
ac8ca46f0f
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -50,7 +50,6 @@
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" />
|
||||
<PackageReference Include="Braintree" Version="4.18.0" />
|
||||
<PackageReference Include="Stripe.net" Version="37.26.0" />
|
||||
<PackageReference Include="U2F.Core" Version="1.0.4" />
|
||||
<PackageReference Include="Otp.NET" Version="1.2.2" />
|
||||
<PackageReference Include="YubicoDotNetClient" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
||||
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Entities
|
||||
{
|
||||
public class U2f : ITableObject<int>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
Email = 1,
|
||||
Duo = 2,
|
||||
YubiKey = 3,
|
||||
U2f = 4,
|
||||
// U2f = 4, // Deprecated
|
||||
Remember = 5,
|
||||
OrganizationDuo = 6,
|
||||
WebAuthn = 7,
|
||||
|
@ -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<User>
|
||||
{
|
||||
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<bool> CanGenerateTwoFactorTokenAsync(UserManager<User> manager, User user)
|
||||
{
|
||||
var userService = _serviceProvider.GetRequiredService<IUserService>();
|
||||
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<string> GenerateAsync(string purpose, UserManager<User> manager, User user)
|
||||
{
|
||||
var userService = _serviceProvider.GetRequiredService<IUserService>();
|
||||
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<object>();
|
||||
var challengeKeys = new List<object>();
|
||||
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<bool> ValidateAsync(string purpose, string token, UserManager<User> manager, User user)
|
||||
{
|
||||
var userService = _serviceProvider.GetRequiredService<IUserService>();
|
||||
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<AuthenticateResponse>(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<Tuple<string, TwoFactorProvider.U2fMetaData>> LoadKeys(TwoFactorProvider provider)
|
||||
{
|
||||
var keys = new List<Tuple<string, TwoFactorProvider.U2fMetaData>>();
|
||||
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<string, TwoFactorProvider.U2fMetaData>(keyName, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<string, object>
|
||||
{
|
||||
["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)
|
||||
|
@ -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<string, object> MetaData { get; set; } = new Dictionary<string, object>();
|
||||
|
||||
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:
|
||||
|
@ -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<U2f, int>
|
||||
{
|
||||
Task<ICollection<U2f>> GetManyByUserIdAsync(Guid userId);
|
||||
Task DeleteManyByUserIdAsync(Guid userId);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -31,7 +31,6 @@ namespace Bit.Infrastructure.Dapper
|
||||
services.AddSingleton<IProviderUserRepository, ProviderUserRepository>();
|
||||
services.AddSingleton<IProviderOrganizationRepository, ProviderOrganizationRepository>();
|
||||
services.AddSingleton<ITransactionRepository, TransactionRepository>();
|
||||
services.AddSingleton<IU2fRepository, U2fRepository>();
|
||||
services.AddSingleton<IUserRepository, UserRepository>();
|
||||
|
||||
if (selfHosted)
|
||||
|
@ -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<U2f, int>, IU2fRepository
|
||||
{
|
||||
public U2fRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public U2fRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<U2f>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<U2f>(
|
||||
$"[{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();
|
||||
}
|
||||
}
|
||||
}
|
@ -50,7 +50,6 @@ namespace Bit.Infrastructure.EntityFramework
|
||||
services.AddSingleton<ISsoUserRepository, SsoUserRepository>();
|
||||
services.AddSingleton<ITaxRateRepository, TaxRateRepository>();
|
||||
services.AddSingleton<ITransactionRepository, TransactionRepository>();
|
||||
services.AddSingleton<IU2fRepository, U2fRepository>();
|
||||
services.AddSingleton<IUserRepository, UserRepository>();
|
||||
services.AddSingleton<IProviderRepository, ProviderRepository>();
|
||||
services.AddSingleton<IProviderUserRepository, ProviderUserRepository>();
|
||||
|
@ -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<Core.Entities.U2f, U2f>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ namespace Bit.Infrastructure.EntityFramework.Models
|
||||
public virtual ICollection<OrganizationUser> OrganizationUsers { get; set; }
|
||||
public virtual ICollection<SsoUser> SsoUsers { get; set; }
|
||||
public virtual ICollection<Transaction> Transactions { get; set; }
|
||||
public virtual ICollection<U2f> U2fs { get; set; }
|
||||
}
|
||||
|
||||
public class UserMapperProfile : Profile
|
||||
|
@ -36,7 +36,6 @@ namespace Bit.Infrastructure.EntityFramework.Repositories
|
||||
public DbSet<SsoUser> SsoUsers { get; set; }
|
||||
public DbSet<TaxRate> TaxRates { get; set; }
|
||||
public DbSet<Transaction> Transactions { get; set; }
|
||||
public DbSet<U2f> U2fs { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
@ -66,7 +65,6 @@ namespace Bit.Infrastructure.EntityFramework.Repositories
|
||||
var eSsoUser = builder.Entity<SsoUser>();
|
||||
var eTaxRate = builder.Entity<TaxRate>();
|
||||
var eTransaction = builder.Entity<Transaction>();
|
||||
var eU2f = builder.Entity<U2f>();
|
||||
var eUser = builder.Entity<User>();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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<Core.Entities.U2f, U2f, int>, IU2fRepository
|
||||
{
|
||||
public U2fRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
||||
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.U2fs)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<Core.Entities.U2f>> 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<Core.Entities.U2f>)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();
|
||||
}
|
||||
}
|
||||
}
|
@ -335,8 +335,6 @@ namespace Bit.SharedWeb.Utilities
|
||||
CoreHelpers.CustomProviderName(TwoFactorProviderType.YubiKey))
|
||||
.AddTokenProvider<DuoWebTokenProvider>(
|
||||
CoreHelpers.CustomProviderName(TwoFactorProviderType.Duo))
|
||||
.AddTokenProvider<U2fTokenProvider>(
|
||||
CoreHelpers.CustomProviderName(TwoFactorProviderType.U2f))
|
||||
.AddTokenProvider<TwoFactorRememberTokenProvider>(
|
||||
CoreHelpers.CustomProviderName(TwoFactorProviderType.Remember))
|
||||
.AddTokenProvider<EmailTokenProvider<User>>(TokenOptions.DefaultEmailProvider)
|
||||
|
@ -83,7 +83,6 @@
|
||||
<Build Include="dbo\Tables\Grant.sql" />
|
||||
<Build Include="dbo\Tables\SsoConfig.sql" />
|
||||
<Build Include="dbo\Tables\User.sql" />
|
||||
<Build Include="dbo\Tables\U2f.sql" />
|
||||
<Build Include="dbo\Tables\Device.sql" />
|
||||
<Build Include="dbo\Tables\Folder.sql" />
|
||||
<Build Include="dbo\Tables\Cipher.sql" />
|
||||
@ -103,7 +102,6 @@
|
||||
<Build Include="dbo\Views\SsoConfigView.sql" />
|
||||
<Build Include="dbo\Views\SsoUserView.sql" />
|
||||
<Build Include="dbo\Views\UserView.sql" />
|
||||
<Build Include="dbo\Views\U2fView.sql" />
|
||||
<Build Include="dbo\Views\CipherView.sql" />
|
||||
<Build Include="dbo\Views\DeviceView.sql" />
|
||||
<Build Include="dbo\Views\GroupView.sql" />
|
||||
@ -164,9 +162,6 @@
|
||||
<Build Include="dbo\Stored Procedures\CollectionCipher_Delete.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollections.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollectionsAdmin.sql" />
|
||||
<Build Include="dbo\Stored Procedures\U2f_Create.sql" />
|
||||
<Build Include="dbo\Stored Procedures\U2f_DeleteByUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\U2f_ReadByUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_Create.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_DeleteById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Folder_Update.sql" />
|
||||
@ -271,7 +266,6 @@
|
||||
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollectionsForCiphers.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_UpdateRenewalReminderDate.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Grant_DeleteExpired.sql" />
|
||||
<Build Include="dbo\Stored Procedures\U2f_DeleteOld.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_ReadKdfByEmail.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Cipher_DeleteByOrganizationId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\AzureSQLMaintenance.sql" />
|
||||
|
@ -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
|
@ -1,12 +0,0 @@
|
||||
CREATE PROCEDURE [dbo].[U2f_DeleteByUserId]
|
||||
@UserId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[U2f]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
END
|
@ -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
|
@ -1,13 +0,0 @@
|
||||
CREATE PROCEDURE [dbo].[U2f_ReadByUserId]
|
||||
@UserId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[U2fView]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
END
|
@ -72,13 +72,6 @@ BEGIN
|
||||
WHERE
|
||||
[UserId] = @Id
|
||||
|
||||
-- Delete U2F logins
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[U2f]
|
||||
WHERE
|
||||
[UserId] = @Id
|
||||
|
||||
-- Delete SSO Users
|
||||
DELETE
|
||||
FROM
|
||||
|
@ -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);
|
||||
|
@ -1,6 +0,0 @@
|
||||
CREATE VIEW [dbo].[U2fView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[U2f]
|
@ -88,7 +88,6 @@ namespace Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures
|
||||
cfg.AddProfile<SsoUserMapperProfile>();
|
||||
cfg.AddProfile<TaxRateMapperProfile>();
|
||||
cfg.AddProfile<TransactionMapperProfile>();
|
||||
cfg.AddProfile<U2fMapperProfile>();
|
||||
cfg.AddProfile<UserMapperProfile>();
|
||||
})
|
||||
.CreateMapper()));
|
||||
|
@ -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<U2f>();
|
||||
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<U2fRepository>());
|
||||
fixture.Customizations.Add(new EfRepositoryListBuilder<UserRepository>());
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
@ -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<U2fTokenProvider>
|
||||
{
|
||||
public override TwoFactorProviderType TwoFactorProviderType => TwoFactorProviderType.U2f;
|
||||
|
||||
public static IEnumerable<object[]> CanGenerateTwoFactorTokenAsyncData()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new object[]
|
||||
{
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
["Something"] = "Hello"
|
||||
},
|
||||
true, // canAccessPremium
|
||||
true, // expectedResponse
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new Dictionary<string, object>(),
|
||||
true, // canAccessPremium
|
||||
false, // expectedResponse
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
["Key"] = "Value"
|
||||
},
|
||||
false, // canAccessPremium
|
||||
false, // expectedResponse
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[Theory, BitMemberAutoData(nameof(CanGenerateTwoFactorTokenAsyncData))]
|
||||
public async Task CanGenerateTwoFactorTokenAsync_Success(Dictionary<string, object> metaData, bool canAccessPremium,
|
||||
bool expectedResponse, User user, SutProvider<U2fTokenProvider> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<U2f>
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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<EfRepo.U2fRepository> suts,
|
||||
List<EfRepo.UserRepository> efUserRepos,
|
||||
SqlRepo.U2fRepository sqlU2fRepo,
|
||||
SqlRepo.UserRepository sqlUserRepo
|
||||
)
|
||||
{
|
||||
var savedU2fs = new List<U2f>();
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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<IDbCommand> commandFactory)
|
||||
{
|
||||
var cmd = commandFactory();
|
||||
cmd.CommandText = "SELECT Id, TwoFactorProviders FROM [dbo].[User] WHERE TwoFactorProviders IS NOT NULL";
|
||||
|
||||
var users = new List<object>();
|
||||
|
||||
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<Dictionary<TwoFactorProviderType, TwoFactorProvider>>(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<Tuple<string, TwoFactorProvider.U2fMetaData>> LoadKeys(TwoFactorProvider provider)
|
||||
{
|
||||
var keys = new List<Tuple<string, TwoFactorProvider.U2fMetaData>>();
|
||||
|
||||
// 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<string, TwoFactorProvider.U2fMetaData>(keyName, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
private class User
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string TwoFactorProviders { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
154
util/Migrator/DbScripts/2022-01-21_00_RemoveU2F.sql
Normal file
154
util/Migrator/DbScripts/2022-01-21_00_RemoveU2F.sql
Normal file
@ -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
|
1522
util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.Designer.cs
generated
Normal file
1522
util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
52
util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.cs
Normal file
52
util/MySqlMigrations/Migrations/20220121092546_RemoveU2F.cs
Normal file
@ -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<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
AppId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Challenge = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
KeyHandle = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Version = table.Column<string>(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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<string>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<long>("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<long>("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<string>("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<Guid>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AppId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<string>("Challenge")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("KeyHandle")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("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<Guid>("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
|
||||
}
|
||||
|
BIN
util/MySqlMigrations/Scripts/2022-01-21_00_RemoveU2F.sql
Normal file
BIN
util/MySqlMigrations/Scripts/2022-01-21_00_RemoveU2F.sql
Normal file
Binary file not shown.
1530
util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.Designer.cs
generated
Normal file
1530
util/PostgresMigrations/Migrations/20220121092321_RemoveU2F.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -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<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
AppId = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
||||
Challenge = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
||||
CreationDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
KeyHandle = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
||||
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Version = table.Column<string>(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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<string>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<Guid>("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<long>("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<long>("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<string>("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<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
@ -1041,43 +1041,7 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.ToTable("Transaction");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Core.Models.EntityFramework.U2f", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("AppId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.Property<string>("Challenge")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("KeyHandle")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("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<Guid>("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
|
||||
}
|
||||
|
BIN
util/PostgresMigrations/Scripts/2022-01-21_00_RemoveU2F.psql
Normal file
BIN
util/PostgresMigrations/Scripts/2022-01-21_00_RemoveU2F.psql
Normal file
Binary file not shown.
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user