From 12966c63a600ffca6c3eb4fb62a90a8e2dc1bec0 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 12 Dec 2018 10:04:36 -0800 Subject: [PATCH] Change DataProtection projects to target netcoreapp3.0 #3754 (#4473) --- build/artifacts.props | 1 - eng/ProjectReferences.props | 1 - ...NetCore.DataProtection.Abstractions.csproj | 2 +- ...e.DataProtection.Abstractions.Tests.csproj | 2 +- ...etCore.DataProtection.AzureKeyVault.csproj | 2 +- ....DataProtection.AzureKeyVault.Tests.csproj | 2 +- ...NetCore.DataProtection.AzureStorage.csproj | 2 +- ...e.DataProtection.AzureStorage.Tests.csproj | 2 +- ...ft.AspNetCore.Cryptography.Internal.csproj | 2 +- ...NetCore.Cryptography.Internal.Tests.csproj | 2 +- ...pNetCore.Cryptography.KeyDerivation.csproj | 2 +- ...re.Cryptography.KeyDerivation.Tests.csproj | 2 +- src/DataProtection/DataProtection.sln | 15 -- ...Microsoft.AspNetCore.DataProtection.csproj | 2 +- ...oft.AspNetCore.DataProtection.Tests.csproj | 2 +- ....DataProtection.EntityFrameworkCore.csproj | 2 +- ...Protection.EntityFrameworkCore.Test.csproj | 2 +- ...spNetCore.DataProtection.Extensions.csproj | 2 +- ...ore.DataProtection.Extensions.Tests.csproj | 2 +- ...e.DataProtection.StackExchangeRedis.csproj | 2 +- ...Protection.StackExchangeRedis.Tests.csproj | 2 +- .../src/CompatibilityDataProtector.cs | 133 --------------- .../SystemWeb/src/DataProtectionStartup.cs | 102 ------------ ...AspNetCore.DataProtection.SystemWeb.csproj | 22 --- .../src/Properties/Resources.Designer.cs | 58 ------- .../SystemWeb/src/Resources.resx | 126 -------------- .../SystemWeb/src/baseline.netframework.json | 157 ------------------ .../SystemWeb/src/web.config.transform | 14 -- .../CustomEncryptorSample.csproj | 2 +- .../EntityFrameworkCoreSample.csproj | 2 +- .../KeyManagementSample.csproj | 2 +- .../samples/NonDISample/NonDISample.csproj | 2 +- src/DataProtection/samples/Redis/Redis.csproj | 2 +- 33 files changed, 23 insertions(+), 652 deletions(-) delete mode 100644 src/DataProtection/SystemWeb/src/CompatibilityDataProtector.cs delete mode 100644 src/DataProtection/SystemWeb/src/DataProtectionStartup.cs delete mode 100644 src/DataProtection/SystemWeb/src/Microsoft.AspNetCore.DataProtection.SystemWeb.csproj delete mode 100644 src/DataProtection/SystemWeb/src/Properties/Resources.Designer.cs delete mode 100644 src/DataProtection/SystemWeb/src/Resources.resx delete mode 100644 src/DataProtection/SystemWeb/src/baseline.netframework.json delete mode 100644 src/DataProtection/SystemWeb/src/web.config.transform diff --git a/build/artifacts.props b/build/artifacts.props index dbe6135b65..b69363a093 100644 --- a/build/artifacts.props +++ b/build/artifacts.props @@ -115,7 +115,6 @@ - diff --git a/eng/ProjectReferences.props b/eng/ProjectReferences.props index 080f4c9659..c7d5ab8130 100644 --- a/eng/ProjectReferences.props +++ b/eng/ProjectReferences.props @@ -12,7 +12,6 @@ - diff --git a/src/DataProtection/Abstractions/src/Microsoft.AspNetCore.DataProtection.Abstractions.csproj b/src/DataProtection/Abstractions/src/Microsoft.AspNetCore.DataProtection.Abstractions.csproj index 021b3fde2c..2beeb5f0bb 100644 --- a/src/DataProtection/Abstractions/src/Microsoft.AspNetCore.DataProtection.Abstractions.csproj +++ b/src/DataProtection/Abstractions/src/Microsoft.AspNetCore.DataProtection.Abstractions.csproj @@ -5,7 +5,7 @@ Commonly used types: Microsoft.AspNetCore.DataProtection.IDataProtectionProvider Microsoft.AspNetCore.DataProtection.IDataProtector - netstandard2.0 + netcoreapp3.0 true aspnetcore;dataprotection diff --git a/src/DataProtection/Abstractions/test/Microsoft.AspNetCore.DataProtection.Abstractions.Tests.csproj b/src/DataProtection/Abstractions/test/Microsoft.AspNetCore.DataProtection.Abstractions.Tests.csproj index 781387c466..0f17586d23 100644 --- a/src/DataProtection/Abstractions/test/Microsoft.AspNetCore.DataProtection.Abstractions.Tests.csproj +++ b/src/DataProtection/Abstractions/test/Microsoft.AspNetCore.DataProtection.Abstractions.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 diff --git a/src/DataProtection/AzureKeyVault/src/Microsoft.AspNetCore.DataProtection.AzureKeyVault.csproj b/src/DataProtection/AzureKeyVault/src/Microsoft.AspNetCore.DataProtection.AzureKeyVault.csproj index 42aa2edb13..58167df456 100644 --- a/src/DataProtection/AzureKeyVault/src/Microsoft.AspNetCore.DataProtection.AzureKeyVault.csproj +++ b/src/DataProtection/AzureKeyVault/src/Microsoft.AspNetCore.DataProtection.AzureKeyVault.csproj @@ -2,7 +2,7 @@ Microsoft Azure KeyVault key encryption support. - netstandard2.0 + netcoreapp3.0 true aspnetcore;dataprotection;azure;keyvault false diff --git a/src/DataProtection/AzureKeyVault/test/Microsoft.AspNetCore.DataProtection.AzureKeyVault.Tests.csproj b/src/DataProtection/AzureKeyVault/test/Microsoft.AspNetCore.DataProtection.AzureKeyVault.Tests.csproj index 879b9042a1..17b9fe4ac8 100644 --- a/src/DataProtection/AzureKeyVault/test/Microsoft.AspNetCore.DataProtection.AzureKeyVault.Tests.csproj +++ b/src/DataProtection/AzureKeyVault/test/Microsoft.AspNetCore.DataProtection.AzureKeyVault.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 true diff --git a/src/DataProtection/AzureStorage/src/Microsoft.AspNetCore.DataProtection.AzureStorage.csproj b/src/DataProtection/AzureStorage/src/Microsoft.AspNetCore.DataProtection.AzureStorage.csproj index d65f55a425..d7042db87a 100644 --- a/src/DataProtection/AzureStorage/src/Microsoft.AspNetCore.DataProtection.AzureStorage.csproj +++ b/src/DataProtection/AzureStorage/src/Microsoft.AspNetCore.DataProtection.AzureStorage.csproj @@ -2,7 +2,7 @@ Microsoft Azure Blob storrage support as key store. - netstandard2.0 + netcoreapp3.0 true true aspnetcore;dataprotection;azure;blob diff --git a/src/DataProtection/AzureStorage/test/Microsoft.AspNetCore.DataProtection.AzureStorage.Tests.csproj b/src/DataProtection/AzureStorage/test/Microsoft.AspNetCore.DataProtection.AzureStorage.Tests.csproj index f84e84974e..ed16b18390 100644 --- a/src/DataProtection/AzureStorage/test/Microsoft.AspNetCore.DataProtection.AzureStorage.Tests.csproj +++ b/src/DataProtection/AzureStorage/test/Microsoft.AspNetCore.DataProtection.AzureStorage.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 true diff --git a/src/DataProtection/Cryptography.Internal/src/Microsoft.AspNetCore.Cryptography.Internal.csproj b/src/DataProtection/Cryptography.Internal/src/Microsoft.AspNetCore.Cryptography.Internal.csproj index ff4ef3babe..9859f30a11 100644 --- a/src/DataProtection/Cryptography.Internal/src/Microsoft.AspNetCore.Cryptography.Internal.csproj +++ b/src/DataProtection/Cryptography.Internal/src/Microsoft.AspNetCore.Cryptography.Internal.csproj @@ -2,7 +2,7 @@ Infrastructure for ASP.NET Core cryptographic packages. Applications and libraries should not reference this package directly. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true true diff --git a/src/DataProtection/Cryptography.Internal/test/Microsoft.AspNetCore.Cryptography.Internal.Tests.csproj b/src/DataProtection/Cryptography.Internal/test/Microsoft.AspNetCore.Cryptography.Internal.Tests.csproj index 29e8a7c294..1fa55228db 100644 --- a/src/DataProtection/Cryptography.Internal/test/Microsoft.AspNetCore.Cryptography.Internal.Tests.csproj +++ b/src/DataProtection/Cryptography.Internal/test/Microsoft.AspNetCore.Cryptography.Internal.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 true diff --git a/src/DataProtection/Cryptography.KeyDerivation/src/Microsoft.AspNetCore.Cryptography.KeyDerivation.csproj b/src/DataProtection/Cryptography.KeyDerivation/src/Microsoft.AspNetCore.Cryptography.KeyDerivation.csproj index 3b869383e6..69982996dc 100644 --- a/src/DataProtection/Cryptography.KeyDerivation/src/Microsoft.AspNetCore.Cryptography.KeyDerivation.csproj +++ b/src/DataProtection/Cryptography.KeyDerivation/src/Microsoft.AspNetCore.Cryptography.KeyDerivation.csproj @@ -2,7 +2,7 @@ ASP.NET Core utilities for key derivation. - netstandard2.0;netcoreapp3.0 + netcoreapp3.0 true true aspnetcore;dataprotection diff --git a/src/DataProtection/Cryptography.KeyDerivation/test/Microsoft.AspNetCore.Cryptography.KeyDerivation.Tests.csproj b/src/DataProtection/Cryptography.KeyDerivation/test/Microsoft.AspNetCore.Cryptography.KeyDerivation.Tests.csproj index e7a1be7ece..5d3ff930af 100644 --- a/src/DataProtection/Cryptography.KeyDerivation/test/Microsoft.AspNetCore.Cryptography.KeyDerivation.Tests.csproj +++ b/src/DataProtection/Cryptography.KeyDerivation/test/Microsoft.AspNetCore.Cryptography.KeyDerivation.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 true diff --git a/src/DataProtection/DataProtection.sln b/src/DataProtection/DataProtection.sln index 5300acb57a..48b89d6e00 100644 --- a/src/DataProtection/DataProtection.sln +++ b/src/DataProtection/DataProtection.sln @@ -65,8 +65,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NonDISample", "samples\NonD EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Redis", "samples\Redis\Redis.csproj", "{E578D5C2-76AD-4A9B-A4F0-3A74D7ACD98E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SystemWeb", "SystemWeb", "{AA4BAE43-BD74-4292-8468-46F4DF60F9C7}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.DataProtection.SystemWeb", "SystemWeb\src\Microsoft.AspNetCore.DataProtection.SystemWeb.csproj", "{A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EntityFrameworkCore", "EntityFrameworkCore", "{64FD02D7-B6F4-4C77-A3F8-E6BD6404168E}" @@ -352,18 +350,6 @@ Global {E578D5C2-76AD-4A9B-A4F0-3A74D7ACD98E}.Release|x64.Build.0 = Release|Any CPU {E578D5C2-76AD-4A9B-A4F0-3A74D7ACD98E}.Release|x86.ActiveCfg = Release|Any CPU {E578D5C2-76AD-4A9B-A4F0-3A74D7ACD98E}.Release|x86.Build.0 = Release|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Debug|x64.ActiveCfg = Debug|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Debug|x64.Build.0 = Debug|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Debug|x86.ActiveCfg = Debug|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Debug|x86.Build.0 = Debug|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Release|Any CPU.Build.0 = Release|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Release|x64.ActiveCfg = Release|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Release|x64.Build.0 = Release|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Release|x86.ActiveCfg = Release|Any CPU - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7}.Release|x86.Build.0 = Release|Any CPU {8A7D0D2D-A5F1-4DF7-BBAA-9A0EFDBB5224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8A7D0D2D-A5F1-4DF7-BBAA-9A0EFDBB5224}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A7D0D2D-A5F1-4DF7-BBAA-9A0EFDBB5224}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -412,7 +398,6 @@ Global {03406538-75CB-4655-B210-643FE11A2B00} = {9DF098B3-C8ED-471C-AE03-52E3196C1811} {C5C425C8-5626-409B-9A81-4DC496CE41F4} = {9DF098B3-C8ED-471C-AE03-52E3196C1811} {E578D5C2-76AD-4A9B-A4F0-3A74D7ACD98E} = {9DF098B3-C8ED-471C-AE03-52E3196C1811} - {A65DAFB6-E03F-4140-892F-D7CA3B8D81D7} = {AA4BAE43-BD74-4292-8468-46F4DF60F9C7} {8A7D0D2D-A5F1-4DF7-BBAA-9A0EFDBB5224} = {64FD02D7-B6F4-4C77-A3F8-E6BD6404168E} {74CE0E8B-DE23-4B53-8D02-69D6FB849ADC} = {64FD02D7-B6F4-4C77-A3F8-E6BD6404168E} EndGlobalSection diff --git a/src/DataProtection/DataProtection/src/Microsoft.AspNetCore.DataProtection.csproj b/src/DataProtection/DataProtection/src/Microsoft.AspNetCore.DataProtection.csproj index 18aa5ddc40..c843a00dd4 100644 --- a/src/DataProtection/DataProtection/src/Microsoft.AspNetCore.DataProtection.csproj +++ b/src/DataProtection/DataProtection/src/Microsoft.AspNetCore.DataProtection.csproj @@ -2,7 +2,7 @@ ASP.NET Core logic to protect and unprotect data, similar to DPAPI. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true true diff --git a/src/DataProtection/DataProtection/test/Microsoft.AspNetCore.DataProtection.Tests.csproj b/src/DataProtection/DataProtection/test/Microsoft.AspNetCore.DataProtection.Tests.csproj index 3886642178..2dd82b92b4 100644 --- a/src/DataProtection/DataProtection/test/Microsoft.AspNetCore.DataProtection.Tests.csproj +++ b/src/DataProtection/DataProtection/test/Microsoft.AspNetCore.DataProtection.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 true diff --git a/src/DataProtection/EntityFrameworkCore/src/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.csproj b/src/DataProtection/EntityFrameworkCore/src/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.csproj index 85f5e47c55..f0713f0ecb 100644 --- a/src/DataProtection/EntityFrameworkCore/src/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.csproj +++ b/src/DataProtection/EntityFrameworkCore/src/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.csproj @@ -2,7 +2,7 @@ Support for storing keys using Entity Framework Core. - netstandard2.0 + netcoreapp3.0 true true aspnetcore;dataprotection;entityframeworkcore diff --git a/src/DataProtection/EntityFrameworkCore/test/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.Test.csproj b/src/DataProtection/EntityFrameworkCore/test/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.Test.csproj index f08eb96c9b..6d3e504879 100644 --- a/src/DataProtection/EntityFrameworkCore/test/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.Test.csproj +++ b/src/DataProtection/EntityFrameworkCore/test/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.Test.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 diff --git a/src/DataProtection/Extensions/src/Microsoft.AspNetCore.DataProtection.Extensions.csproj b/src/DataProtection/Extensions/src/Microsoft.AspNetCore.DataProtection.Extensions.csproj index c106a52961..7a4c008f78 100644 --- a/src/DataProtection/Extensions/src/Microsoft.AspNetCore.DataProtection.Extensions.csproj +++ b/src/DataProtection/Extensions/src/Microsoft.AspNetCore.DataProtection.Extensions.csproj @@ -2,7 +2,7 @@ Additional APIs for ASP.NET Core data protection. - netstandard2.0 + netcoreapp3.0 true aspnetcore;dataprotection diff --git a/src/DataProtection/Extensions/test/Microsoft.AspNetCore.DataProtection.Extensions.Tests.csproj b/src/DataProtection/Extensions/test/Microsoft.AspNetCore.DataProtection.Extensions.Tests.csproj index 19284dddfd..1df9abdd17 100644 --- a/src/DataProtection/Extensions/test/Microsoft.AspNetCore.DataProtection.Extensions.Tests.csproj +++ b/src/DataProtection/Extensions/test/Microsoft.AspNetCore.DataProtection.Extensions.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 diff --git a/src/DataProtection/StackExchangeRedis/src/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.csproj b/src/DataProtection/StackExchangeRedis/src/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.csproj index 6e2143d602..a53d924f3c 100644 --- a/src/DataProtection/StackExchangeRedis/src/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.csproj +++ b/src/DataProtection/StackExchangeRedis/src/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.csproj @@ -2,7 +2,7 @@ Support for storing data protection keys in Redis. - netstandard2.0 + netcoreapp3.0 true true aspnetcore;dataprotection;redis diff --git a/src/DataProtection/StackExchangeRedis/test/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.Tests.csproj b/src/DataProtection/StackExchangeRedis/test/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.Tests.csproj index 964abdb650..ff9e397e77 100644 --- a/src/DataProtection/StackExchangeRedis/test/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.Tests.csproj +++ b/src/DataProtection/StackExchangeRedis/test/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0;net461 + netcoreapp3.0 diff --git a/src/DataProtection/SystemWeb/src/CompatibilityDataProtector.cs b/src/DataProtection/SystemWeb/src/CompatibilityDataProtector.cs deleted file mode 100644 index 739afe83bd..0000000000 --- a/src/DataProtection/SystemWeb/src/CompatibilityDataProtector.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.ComponentModel; -using System.Configuration; -using System.Security.Cryptography; - -namespace Microsoft.AspNetCore.DataProtection.SystemWeb -{ - /// - /// A that can be used by ASP.NET 4.x to interact with ASP.NET Core's - /// DataProtection stack. This type is for internal use only and shouldn't be directly used by - /// developers. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public sealed class CompatibilityDataProtector : DataProtector - { - private static readonly Lazy _lazyProtectionProvider = new Lazy(CreateProtectionProvider); - - [ThreadStatic] - private static bool _suppressPrimaryPurpose; - - private readonly Lazy _lazyProtector; - private readonly Lazy _lazyProtectorSuppressedPrimaryPurpose; - - public CompatibilityDataProtector(string applicationName, string primaryPurpose, string[] specificPurposes) - : base("application-name", "primary-purpose", null) // we feed dummy values to the base ctor - { - // We don't want to evaluate the IDataProtectionProvider factory quite yet, - // as we'd rather defer failures to the call to Protect so that we can bubble - // up a good error message to the developer. - - _lazyProtector = new Lazy(() => _lazyProtectionProvider.Value.CreateProtector(primaryPurpose, specificPurposes)); - - // System.Web always provides "User.MachineKey.Protect" as the primary purpose for calls - // to MachineKey.Protect. Only in this case should we allow suppressing the primary - // purpose, as then we can easily map calls to MachineKey.Protect(userData, purposes) - // into calls to provider.GetProtector(purposes).Protect(userData). - if (primaryPurpose == "User.MachineKey.Protect") - { - _lazyProtectorSuppressedPrimaryPurpose = new Lazy(() => _lazyProtectionProvider.Value.CreateProtector(specificPurposes)); - } - else - { - _lazyProtectorSuppressedPrimaryPurpose = _lazyProtector; - } - } - - // We take care of flowing purposes ourselves. - protected override bool PrependHashedPurposeToPlaintext { get; } = false; - - // Retrieves the appropriate protector (potentially with a suppressed primary purpose) for this operation. - private IDataProtector Protector => ((_suppressPrimaryPurpose) ? _lazyProtectorSuppressedPrimaryPurpose : _lazyProtector).Value; - - private static IDataProtectionProvider CreateProtectionProvider() - { - // Read from the startup type we need to use, then create it - const string APPSETTINGS_KEY = "aspnet:dataProtectionStartupType"; - string startupTypeName = ConfigurationManager.AppSettings[APPSETTINGS_KEY]; - if (String.IsNullOrEmpty(startupTypeName)) - { - // fall back to default startup type if one hasn't been specified in config - startupTypeName = typeof(DataProtectionStartup).AssemblyQualifiedName; - } - Type startupType = Type.GetType(startupTypeName, throwOnError: true); - var startupInstance = (DataProtectionStartup)Activator.CreateInstance(startupType); - - // Use it to initialize the system. - return startupInstance.InternalConfigureServicesAndCreateProtectionProvider(); - } - - public override bool IsReprotectRequired(byte[] encryptedData) - { - // Nobody ever calls this. - return false; - } - - protected override byte[] ProviderProtect(byte[] userData) - { - try - { - return Protector.Protect(userData); - } - catch (Exception ex) - { - // System.Web special-cases ConfigurationException errors and allows them to bubble - // up to the developer without being homogenized. Since a call to Protect should - // never fail, any exceptions here really do imply a misconfiguration. - -#pragma warning disable CS0618 // Type or member is obsolete - throw new ConfigurationException(Resources.DataProtector_ProtectFailed, ex); -#pragma warning restore CS0618 // Type or member is obsolete - } - } - - protected override byte[] ProviderUnprotect(byte[] encryptedData) - { - return Protector.Unprotect(encryptedData); - } - - /// - /// Invokes a delegate where calls to - /// and will ignore the primary - /// purpose and instead use only the sub-purposes. - /// - public static byte[] RunWithSuppressedPrimaryPurpose(Func callback, object state, byte[] input) - { - if (_suppressPrimaryPurpose) - { - return callback(state, input); // already suppressed - just forward call - } - - try - { - try - { - _suppressPrimaryPurpose = true; - return callback(state, input); - } - finally - { - _suppressPrimaryPurpose = false; - } - } - catch - { - // defeat exception filters - throw; - } - } - } -} diff --git a/src/DataProtection/SystemWeb/src/DataProtectionStartup.cs b/src/DataProtection/SystemWeb/src/DataProtectionStartup.cs deleted file mode 100644 index f3760df207..0000000000 --- a/src/DataProtection/SystemWeb/src/DataProtectionStartup.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Configuration; -using System.Web; -using System.Web.Configuration; -using Microsoft.AspNetCore.DataProtection.Infrastructure; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.AspNetCore.DataProtection.SystemWeb -{ - /// - /// Allows controlling the configuration of the ASP.NET Core Data Protection system. - /// - /// - /// Developers should not call these APIs directly. Instead, developers should subclass - /// this type and override the - /// method or methods - /// as appropriate. - /// - public class DataProtectionStartup - { - /// - /// Configures services used by the Data Protection system. - /// - /// A mutable collection of services. - /// - /// Developers may override this method to change the default behaviors of - /// the Data Protection system. - /// - public virtual void ConfigureServices(IServiceCollection services) - { - // InternalConfigureServices already takes care of default configuration. - // The reason we don't configure default logic in this method is that we don't - // want to punish the developer for forgetting to call base.ConfigureServices - // from within his own override. - } - - /// - /// Creates a new instance of an . - /// - /// A collection of services from which to create the . - /// An . - /// - /// Developers should generally override the - /// method instead of this method. - /// - public virtual IDataProtectionProvider CreateDataProtectionProvider(IServiceProvider services) - { - return services.GetDataProtectionProvider(); - } - - /// - /// Provides a default implementation of required services, calls the developer's - /// configuration overrides, then creates an . - /// - internal IDataProtectionProvider InternalConfigureServicesAndCreateProtectionProvider() - { - // Configure the default implementation, passing in our custom discriminator - var services = new ServiceCollection(); - services.AddDataProtection(); - services.AddSingleton(new SystemWebApplicationDiscriminator()); - - // Run user-specified configuration and get an instance of the provider - ConfigureServices(services); - var provider = CreateDataProtectionProvider(services.BuildServiceProvider()); - if (provider == null) - { - throw new InvalidOperationException(Resources.Startup_CreateProviderReturnedNull); - } - - // And we're done! - return provider; - } - - private sealed class SystemWebApplicationDiscriminator : IApplicationDiscriminator - { - private readonly Lazy _lazyDiscriminator = new Lazy(GetAppDiscriminatorCore); - - public string Discriminator => _lazyDiscriminator.Value; - - private static string GetAppDiscriminatorCore() - { - // Try reading the discriminator from defined - // at the web app root. If the value was set explicitly (even if the value is empty), - // honor it as the discriminator. - var machineKeySection = (MachineKeySection)WebConfigurationManager.GetWebApplicationSection("system.web/machineKey"); - if (machineKeySection.ElementInformation.Properties["applicationName"].ValueOrigin != PropertyValueOrigin.Default) - { - return machineKeySection.ApplicationName; - } - else - { - // Otherwise, fall back to the IIS metabase config path. - // This is unique per machine. - return HttpRuntime.AppDomainAppId; - } - } - } - } -} diff --git a/src/DataProtection/SystemWeb/src/Microsoft.AspNetCore.DataProtection.SystemWeb.csproj b/src/DataProtection/SystemWeb/src/Microsoft.AspNetCore.DataProtection.SystemWeb.csproj deleted file mode 100644 index 603fe68cc8..0000000000 --- a/src/DataProtection/SystemWeb/src/Microsoft.AspNetCore.DataProtection.SystemWeb.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - A component to allow the ASP.NET Core data protection stack to work with the ASP.NET 4.x <machineKey> element. - net461 - $(NoWarn);CS1591 - true - aspnet;aspnetcore;dataprotection - - - - - - - - - - - - - - diff --git a/src/DataProtection/SystemWeb/src/Properties/Resources.Designer.cs b/src/DataProtection/SystemWeb/src/Properties/Resources.Designer.cs deleted file mode 100644 index ddc7e53910..0000000000 --- a/src/DataProtection/SystemWeb/src/Properties/Resources.Designer.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -namespace Microsoft.AspNetCore.DataProtection.SystemWeb -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class Resources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNetCore.DataProtection.SystemWeb.Resources", typeof(Resources).GetTypeInfo().Assembly); - - /// - /// A call to Protect failed. This most likely means that the data protection system is misconfigured. See the inner exception for more information. - /// - internal static string DataProtector_ProtectFailed - { - get => GetString("DataProtector_ProtectFailed"); - } - - /// - /// A call to Protect failed. This most likely means that the data protection system is misconfigured. See the inner exception for more information. - /// - internal static string FormatDataProtector_ProtectFailed() - => GetString("DataProtector_ProtectFailed"); - - /// - /// The CreateDataProtectionProvider method returned null. - /// - internal static string Startup_CreateProviderReturnedNull - { - get => GetString("Startup_CreateProviderReturnedNull"); - } - - /// - /// The CreateDataProtectionProvider method returned null. - /// - internal static string FormatStartup_CreateProviderReturnedNull() - => GetString("Startup_CreateProviderReturnedNull"); - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/src/DataProtection/SystemWeb/src/Resources.resx b/src/DataProtection/SystemWeb/src/Resources.resx deleted file mode 100644 index 0923e71d3c..0000000000 --- a/src/DataProtection/SystemWeb/src/Resources.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - A call to Protect failed. This most likely means that the data protection system is misconfigured. See the inner exception for more information. - - - The CreateDataProtectionProvider method returned null. - - \ No newline at end of file diff --git a/src/DataProtection/SystemWeb/src/baseline.netframework.json b/src/DataProtection/SystemWeb/src/baseline.netframework.json deleted file mode 100644 index c068f832bb..0000000000 --- a/src/DataProtection/SystemWeb/src/baseline.netframework.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.DataProtection.SystemWeb, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.DataProtection.SystemWeb.CompatibilityDataProtector", - "Visibility": "Public", - "Kind": "Class", - "Sealed": true, - "BaseType": "System.Security.Cryptography.DataProtector", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_PrependHashedPurposeToPlaintext", - "Parameters": [], - "ReturnType": "System.Boolean", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "IsReprotectRequired", - "Parameters": [ - { - "Name": "encryptedData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Boolean", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ProviderProtect", - "Parameters": [ - { - "Name": "userData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ProviderUnprotect", - "Parameters": [ - { - "Name": "encryptedData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RunWithSuppressedPrimaryPurpose", - "Parameters": [ - { - "Name": "callback", - "Type": "System.Func" - }, - { - "Name": "state", - "Type": "System.Object" - }, - { - "Name": "input", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "applicationName", - "Type": "System.String" - }, - { - "Name": "primaryPurpose", - "Type": "System.String" - }, - { - "Name": "specificPurposes", - "Type": "System.String[]" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.DataProtection.SystemWeb.DataProtectionStartup", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "ConfigureServices", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateDataProtectionProvider", - "Parameters": [ - { - "Name": "services", - "Type": "System.IServiceProvider" - } - ], - "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ] -} \ No newline at end of file diff --git a/src/DataProtection/SystemWeb/src/web.config.transform b/src/DataProtection/SystemWeb/src/web.config.transform deleted file mode 100644 index 8d5a699252..0000000000 --- a/src/DataProtection/SystemWeb/src/web.config.transform +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/src/DataProtection/samples/CustomEncryptorSample/CustomEncryptorSample.csproj b/src/DataProtection/samples/CustomEncryptorSample/CustomEncryptorSample.csproj index de4c5e9e38..c4afb59727 100644 --- a/src/DataProtection/samples/CustomEncryptorSample/CustomEncryptorSample.csproj +++ b/src/DataProtection/samples/CustomEncryptorSample/CustomEncryptorSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp3.0 + netcoreapp3.0 exe diff --git a/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj b/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj index 1254c35689..c6e228f0e0 100644 --- a/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj +++ b/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj @@ -2,7 +2,7 @@ exe - net461;netcoreapp3.0 + netcoreapp3.0 diff --git a/src/DataProtection/samples/KeyManagementSample/KeyManagementSample.csproj b/src/DataProtection/samples/KeyManagementSample/KeyManagementSample.csproj index 5ec8e7b074..a996ad452a 100644 --- a/src/DataProtection/samples/KeyManagementSample/KeyManagementSample.csproj +++ b/src/DataProtection/samples/KeyManagementSample/KeyManagementSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp3.0 + netcoreapp3.0 exe diff --git a/src/DataProtection/samples/NonDISample/NonDISample.csproj b/src/DataProtection/samples/NonDISample/NonDISample.csproj index 04956556af..8dd5fd3f1a 100644 --- a/src/DataProtection/samples/NonDISample/NonDISample.csproj +++ b/src/DataProtection/samples/NonDISample/NonDISample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp3.0 + netcoreapp3.0 exe diff --git a/src/DataProtection/samples/Redis/Redis.csproj b/src/DataProtection/samples/Redis/Redis.csproj index fe41c02daf..f30e056234 100644 --- a/src/DataProtection/samples/Redis/Redis.csproj +++ b/src/DataProtection/samples/Redis/Redis.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp3.0 + netcoreapp3.0 exe