diff --git a/src/Api/Api.csproj b/src/Api/Api.csproj index 5097f6b158..72a4f80228 100644 --- a/src/Api/Api.csproj +++ b/src/Api/Api.csproj @@ -2,7 +2,7 @@ 1.8.2 - net461 + netcoreapp2.0;net461 Api Bit.Api bitwarden-Api diff --git a/src/Billing/Billing.csproj b/src/Billing/Billing.csproj index 05b4efdcd7..e2d119fba0 100644 --- a/src/Billing/Billing.csproj +++ b/src/Billing/Billing.csproj @@ -2,7 +2,7 @@ 1.8.2 - net461 + netcoreapp2.0;net461 Billing Bit.Billing bitwarden-Billing diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index caf4e69e23..6d2022c99c 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -1,7 +1,7 @@  - net461 + netcoreapp2.0;net461 Core Bit.Core @@ -44,7 +44,6 @@ - @@ -57,7 +56,6 @@ - @@ -65,6 +63,12 @@ + + + + + + diff --git a/src/Core/Identity/YubicoOtpTokenProvider.cs b/src/Core/Identity/YubicoOtpTokenProvider.cs index 319c1d905b..98156d6fab 100644 --- a/src/Core/Identity/YubicoOtpTokenProvider.cs +++ b/src/Core/Identity/YubicoOtpTokenProvider.cs @@ -2,7 +2,9 @@ using Microsoft.AspNetCore.Identity; using Bit.Core.Models.Table; using Bit.Core.Enums; +#if NET461 using YubicoDotNetClient; +#endif using System.Linq; namespace Bit.Core.Identity @@ -55,9 +57,14 @@ namespace Bit.Core.Identity return Task.FromResult(false); } + +#if NET461 var client = new YubicoClient(_globalSettings.Yubico.ClientId, _globalSettings.Yubico.Key); var response = client.Verify(token); return Task.FromResult(response.Status == YubicoResponseStatus.Ok); +#else + return Task.FromResult(false); +#endif } } } diff --git a/src/Core/Services/Implementations/AzureAttachmentStorageService.cs b/src/Core/Services/Implementations/AzureAttachmentStorageService.cs index 7887840f77..f5843c9911 100644 --- a/src/Core/Services/Implementations/AzureAttachmentStorageService.cs +++ b/src/Core/Services/Implementations/AzureAttachmentStorageService.cs @@ -98,24 +98,50 @@ namespace Bit.Core.Services public async Task CleanupAsync(Guid cipherId) { await InitAsync(); - foreach(var blob in _attachmentsContainer.ListBlobs($"temp/{cipherId}", true)) + var segment = await _attachmentsContainer.ListBlobsSegmentedAsync($"temp/{cipherId}", true, + BlobListingDetails.None, 100, null, null, null); + + while(true) { - if(blob is CloudBlockBlob blockBlob) + foreach(var blob in segment.Results) { - await blockBlob.DeleteIfExistsAsync(); + if(blob is CloudBlockBlob blockBlob) + { + await blockBlob.DeleteIfExistsAsync(); + } } + + if(segment.ContinuationToken == null) + { + break; + } + + segment = await _attachmentsContainer.ListBlobsSegmentedAsync(segment.ContinuationToken); } } public async Task DeleteAttachmentsForCipherAsync(Guid cipherId) { await InitAsync(); - foreach(var blob in _attachmentsContainer.ListBlobs(cipherId.ToString(), true)) + var segment = await _attachmentsContainer.ListBlobsSegmentedAsync(cipherId.ToString(), true, + BlobListingDetails.None, 100, null, null, null); + + while(true) { - if(blob is CloudBlockBlob blockBlob) + foreach(var blob in segment.Results) { - await blockBlob.DeleteIfExistsAsync(); + if(blob is CloudBlockBlob blockBlob) + { + await blockBlob.DeleteIfExistsAsync(); + } } + + if(segment.ContinuationToken == null) + { + break; + } + + segment = await _attachmentsContainer.ListBlobsSegmentedAsync(segment.ContinuationToken); } } diff --git a/src/Core/Services/Implementations/AzureQueueBlockIpService.cs b/src/Core/Services/Implementations/AzureQueueBlockIpService.cs index 439a890a75..01fa2699f3 100644 --- a/src/Core/Services/Implementations/AzureQueueBlockIpService.cs +++ b/src/Core/Services/Implementations/AzureQueueBlockIpService.cs @@ -9,6 +9,7 @@ namespace Bit.Core.Services { private readonly CloudQueue _blockIpQueue; private readonly CloudQueue _unblockIpQueue; + private bool _didInit = false; public AzureQueueBlockIpService( GlobalSettings globalSettings) @@ -17,14 +18,12 @@ namespace Bit.Core.Services var queueClient = storageAccount.CreateCloudQueueClient(); _blockIpQueue = queueClient.GetQueueReference("blockip"); - _blockIpQueue.CreateIfNotExists(); - _unblockIpQueue = queueClient.GetQueueReference("unblockip"); - _unblockIpQueue.CreateIfNotExists(); } public async Task BlockIpAsync(string ipAddress, bool permanentBlock) { + await InitAsync(); var message = new CloudQueueMessage(ipAddress); await _blockIpQueue.AddMessageAsync(message); @@ -33,5 +32,17 @@ namespace Bit.Core.Services await _unblockIpQueue.AddMessageAsync(message, null, new TimeSpan(12, 0, 0), null, null); } } + + private async Task InitAsync() + { + if(_didInit) + { + return; + } + + await _blockIpQueue.CreateIfNotExistsAsync(); + await _unblockIpQueue.CreateIfNotExistsAsync(); + _didInit = true; + } } } diff --git a/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs b/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs index 83abc916b1..4b335953db 100644 --- a/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs +++ b/src/Core/Services/Implementations/NotificationHubPushNotificationService.cs @@ -1,4 +1,5 @@ -using System; +#if NET461 +using System; using System.Threading.Tasks; using Bit.Core.Models.Table; using Microsoft.Azure.NotificationHubs; @@ -161,3 +162,4 @@ namespace Bit.Core.Services } } } +#endif diff --git a/src/Core/Services/Implementations/NotificationHubPushRegistrationService.cs b/src/Core/Services/Implementations/NotificationHubPushRegistrationService.cs index 2ea47ac7d5..81f249f268 100644 --- a/src/Core/Services/Implementations/NotificationHubPushRegistrationService.cs +++ b/src/Core/Services/Implementations/NotificationHubPushRegistrationService.cs @@ -1,4 +1,5 @@ -using System; +#if NET461 +using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Azure.NotificationHubs; @@ -144,3 +145,4 @@ namespace Bit.Core.Services } } } +#endif diff --git a/src/Core/Utilities/CoreHelpers.cs b/src/Core/Utilities/CoreHelpers.cs index 6f99a8fc44..c942324894 100644 --- a/src/Core/Utilities/CoreHelpers.cs +++ b/src/Core/Utilities/CoreHelpers.cs @@ -57,9 +57,8 @@ namespace Bit.Core.Utilities public static DataTable ToArrayTVP(this IEnumerable values, string columnName) { - var table = new DataTable(); + var table = new DataTable($"{columnName}Array", "dbo"); table.Columns.Add(columnName, typeof(T)); - table.SetTypeName($"[dbo].[{columnName}Array]"); if(values != null) { @@ -74,8 +73,7 @@ namespace Bit.Core.Utilities public static DataTable ToArrayTVP(this IEnumerable values) { - var table = new DataTable(); - table.SetTypeName("[dbo].[SelectionReadOnlyArray]"); + var table = new DataTable("SelectionReadOnlyArray", "dbo"); var idColumn = new DataColumn("Id", typeof(Guid)); table.Columns.Add(idColumn); diff --git a/src/Core/Utilities/ServiceCollectionExtensions.cs b/src/Core/Utilities/ServiceCollectionExtensions.cs index 9ab5624eb9..e723a5a0ff 100644 --- a/src/Core/Utilities/ServiceCollectionExtensions.cs +++ b/src/Core/Utilities/ServiceCollectionExtensions.cs @@ -52,9 +52,14 @@ namespace Bit.Core.Utilities { services.AddSingleton(); services.AddSingleton(); +#if NET461 services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); +#else + services.AddSingleton(); + services.AddSingleton(); +#endif + services.AddSingleton(); services.AddSingleton(); } @@ -154,6 +159,7 @@ namespace Bit.Core.Utilities public static void AddCustomDataProtectionServices( this IServiceCollection services, IHostingEnvironment env, GlobalSettings globalSettings) { +#if NET461 if(!env.IsDevelopment()) { var dataProtectionCert = CoreHelpers.GetCertificate(globalSettings.DataProtection.CertificateThumbprint); @@ -162,6 +168,7 @@ namespace Bit.Core.Utilities .PersistKeysToAzureBlobStorage(storageAccount, "aspnet-dataprotection/keys.xml") .ProtectKeysWithCertificate(dataProtectionCert); } +#endif } public static GlobalSettings AddGlobalSettingsServices(this IServiceCollection services, diff --git a/src/Identity/Identity.csproj b/src/Identity/Identity.csproj index 3a381e9a2f..b3252d517b 100644 --- a/src/Identity/Identity.csproj +++ b/src/Identity/Identity.csproj @@ -2,7 +2,7 @@ 1.8.2 - net461 + netcoreapp2.0;net461 Identity Bit.Identity bitwarden-Identity diff --git a/util/Mail/Mail.csproj b/util/Mail/Mail.csproj index 7f5115edfd..561573df1e 100644 --- a/util/Mail/Mail.csproj +++ b/util/Mail/Mail.csproj @@ -1,10 +1,8 @@  - netcoreapp1.1 + netcoreapp2.0 Mail - 1.1.1 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 Bit.Mail