From bb03356d1b12ed3effabcb2c65e7e85a23c970d4 Mon Sep 17 00:00:00 2001 From: hotchkj Date: Sat, 2 Jul 2016 16:15:35 +0100 Subject: [PATCH 1/4] First pass of conversion to NETCore tooling - source projects compile again Gets unit tests available again under only NET 4.5.1 Integration tests compile again Tests run & pass from Visual Studio Adds xunit dotnet CLI command Adds more xunit-recommended settings, Visual Studio discovers normal unit tests, fails on integration tests Adds some release notes and tags --- AspNetCore.DataProtection.Aws.sln | 2 +- global.json | 5 +-- ....DataProtection.Aws.IntegrationTests.xproj | 6 +-- .../CombinedManagerIntegrationTests.cs | 28 +++++-------- .../EphemeralXmlRepository.cs | 2 +- .../KmsManagerIntegrationTests.cs | 26 +++++------- .../S3ManagerIntegrationTests.cs | 22 ++++------ .../project.json | 32 ++++++++------- .../AspNetCore.DataProtection.Aws.Kms.xproj | 7 ++-- .../DataProtectionBuilderExtensions.cs | 8 ++-- .../KmsXmlDecryptor.cs | 2 +- .../KmsXmlEncryptor.cs | 2 +- .../project.json | 40 +++++++++++-------- .../AspNetCore.DataProtection.Aws.S3.xproj | 7 ++-- .../DataProtectionBuilderExtensions.cs | 8 ++-- .../S3XmlRepository.cs | 2 +- .../project.json | 40 ++++++++++++------- .../AspNetCore.DataProtection.Aws.Tests.xproj | 8 ++-- .../KmsXmlDecryptorTests.cs | 2 +- .../KmsXmlEncryptorTests.cs | 2 +- .../S3XmlRepositoryConfigTests.cs | 2 +- .../S3XmlRepositoryTests.cs | 2 +- .../project.json | 24 +++++------ 23 files changed, 139 insertions(+), 140 deletions(-) diff --git a/AspNetCore.DataProtection.Aws.sln b/AspNetCore.DataProtection.Aws.sln index c38b462..a9c4ff0 100644 --- a/AspNetCore.DataProtection.Aws.sln +++ b/AspNetCore.DataProtection.Aws.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{851F9F19-EAF9-4C8C-81CD-0C89D4083928}" EndProject diff --git a/global.json b/global.json index e4870b2..ef00003 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,3 @@ { - "projects": [ "src", "test" ], - "sdk": { - "version": "1.0.0-rc1-final" - } + "projects": [ "src", "test", "integrate" ] } diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/AspNetCore.DataProtection.Aws.IntegrationTests.xproj b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/AspNetCore.DataProtection.Aws.IntegrationTests.xproj index 6a175d3..a2e6cb7 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/AspNetCore.DataProtection.Aws.IntegrationTests.xproj +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/AspNetCore.DataProtection.Aws.IntegrationTests.xproj @@ -4,12 +4,12 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + d19ebbf5-fa0e-4ec5-a11f-9b5ac1165b39 AspNetCore.DataProtection.Aws.IntegrationTests ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ 2.0 @@ -17,5 +17,5 @@ - + \ No newline at end of file diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/CombinedManagerIntegrationTests.cs b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/CombinedManagerIntegrationTests.cs index b224520..61864c2 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/CombinedManagerIntegrationTests.cs +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/CombinedManagerIntegrationTests.cs @@ -5,9 +5,9 @@ using Amazon.S3; using AspNetCore.DataProtection.Aws.Kms; using AspNetCore.DataProtection.Aws.S3; -using Microsoft.AspNet.DataProtection.AuthenticatedEncryption.ConfigurationModel; -using Microsoft.AspNet.DataProtection.KeyManagement; -using Microsoft.AspNet.DataProtection.Repositories; +using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel; +using Microsoft.AspNetCore.DataProtection.KeyManagement; +using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; @@ -45,12 +45,9 @@ public async Task ExpectFullKeyManagerExplicitAwsStoreRetrieveToSucceed() var kmsConfig = new KmsXmlEncryptorConfig(KmsIntegrationTests.ApplicationName, KmsIntegrationTests.KmsTestingKey); var serviceCollection = new ServiceCollection(); - serviceCollection.AddDataProtection(); - serviceCollection.ConfigureDataProtection(configure => - { - configure.PersistKeysToAwsS3(s3client, s3Config); - configure.ProtectKeysWithAwsKms(kmsClient, kmsConfig); - }); + serviceCollection.AddDataProtection() + .PersistKeysToAwsS3(s3client, s3Config) + .ProtectKeysWithAwsKms(kmsClient, kmsConfig); var serviceProvider = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService(), @@ -77,14 +74,11 @@ public async Task ExpectFullKeyManagerStoreRetrieveToSucceed() var kmsConfig = new KmsXmlEncryptorConfig(KmsIntegrationTests.ApplicationName, KmsIntegrationTests.KmsTestingKey); var serviceCollection = new ServiceCollection(); - serviceCollection.AddInstance(s3client); - serviceCollection.AddInstance(kmsClient); - serviceCollection.AddDataProtection(); - serviceCollection.ConfigureDataProtection(configure => - { - configure.PersistKeysToAwsS3(s3Config); - configure.ProtectKeysWithAwsKms(kmsConfig); - }); + serviceCollection.AddSingleton(s3client); + serviceCollection.AddSingleton(kmsClient); + serviceCollection.AddDataProtection() + .PersistKeysToAwsS3(s3Config) + .ProtectKeysWithAwsKms(kmsConfig); var serviceProvider = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService(), diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/EphemeralXmlRepository.cs b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/EphemeralXmlRepository.cs index 9287c13..fa2e0bf 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/EphemeralXmlRepository.cs +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/EphemeralXmlRepository.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. // // Copied verbatim as a useful testing internal implementation detail -using Microsoft.AspNet.DataProtection.Repositories; +using Microsoft.AspNetCore.DataProtection.Repositories; using System; using System.Collections.Generic; using System.Linq; diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/KmsManagerIntegrationTests.cs b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/KmsManagerIntegrationTests.cs index 16e35a3..65bbd68 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/KmsManagerIntegrationTests.cs +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/KmsManagerIntegrationTests.cs @@ -3,9 +3,9 @@ using Amazon; using Amazon.KeyManagementService; using AspNetCore.DataProtection.Aws.Kms; -using Microsoft.AspNet.DataProtection.AuthenticatedEncryption.ConfigurationModel; -using Microsoft.AspNet.DataProtection.KeyManagement; -using Microsoft.AspNet.DataProtection.Repositories; +using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel; +using Microsoft.AspNetCore.DataProtection.KeyManagement; +using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; @@ -34,12 +34,9 @@ public void ExpectFullKeyManagerExplicitAwsStoreRetrieveToSucceed() var config = new KmsXmlEncryptorConfig(KmsIntegrationTests.ApplicationName, KmsIntegrationTests.KmsTestingKey); var serviceCollection = new ServiceCollection(); - serviceCollection.AddDataProtection(); - serviceCollection.ConfigureDataProtection(configure => - { - configure.ProtectKeysWithAwsKms(kmsClient, config); - }); - serviceCollection.AddInstance(new EphemeralXmlRepository()); + serviceCollection.AddDataProtection() + .ProtectKeysWithAwsKms(kmsClient, config); + serviceCollection.AddSingleton(); var serviceProvider = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService(), @@ -63,13 +60,10 @@ public void ExpectFullKeyManagerStoreRetrieveToSucceed() var config = new KmsXmlEncryptorConfig(KmsIntegrationTests.ApplicationName, KmsIntegrationTests.KmsTestingKey); var serviceCollection = new ServiceCollection(); - serviceCollection.AddInstance(kmsClient); - serviceCollection.AddDataProtection(); - serviceCollection.ConfigureDataProtection(configure => - { - configure.ProtectKeysWithAwsKms(config); - }); - serviceCollection.AddInstance(new EphemeralXmlRepository()); + serviceCollection.AddSingleton(kmsClient); + serviceCollection.AddDataProtection() + .ProtectKeysWithAwsKms(config); + serviceCollection.AddSingleton(); var serviceProvider = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService(), diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/S3ManagerIntegrationTests.cs b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/S3ManagerIntegrationTests.cs index be0f2e6..85722e0 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/S3ManagerIntegrationTests.cs +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/S3ManagerIntegrationTests.cs @@ -3,9 +3,9 @@ using Amazon; using Amazon.S3; using AspNetCore.DataProtection.Aws.S3; -using Microsoft.AspNet.DataProtection.AuthenticatedEncryption.ConfigurationModel; -using Microsoft.AspNet.DataProtection.KeyManagement; -using Microsoft.AspNet.DataProtection.Repositories; +using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel; +using Microsoft.AspNetCore.DataProtection.KeyManagement; +using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; @@ -39,11 +39,8 @@ public async Task ExpectFullKeyManagerExplicitAwsStoreRetrieveToSucceed() await s3cleanup.ClearKeys(S3IntegrationTests.BucketName, config.KeyPrefix); var serviceCollection = new ServiceCollection(); - serviceCollection.AddDataProtection(); - serviceCollection.ConfigureDataProtection(configure => - { - configure.PersistKeysToAwsS3(s3client, config); - }); + serviceCollection.AddDataProtection() + .PersistKeysToAwsS3(s3client, config); var serviceProvider = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService(), @@ -69,12 +66,9 @@ public async Task ExpectFullKeyManagerStoreRetrieveToSucceed() await s3cleanup.ClearKeys(S3IntegrationTests.BucketName, config.KeyPrefix); var serviceCollection = new ServiceCollection(); - serviceCollection.AddInstance(s3client); - serviceCollection.AddDataProtection(); - serviceCollection.ConfigureDataProtection(configure => - { - configure.PersistKeysToAwsS3(config); - }); + serviceCollection.AddSingleton(s3client); + serviceCollection.AddDataProtection() + .PersistKeysToAwsS3(config); var serviceProvider = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService(), diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json index ad4697b..44eec62 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json @@ -1,29 +1,33 @@ { - "summary": "ASP.NET DataProtection Repository Integration Tests", - "licenseUrl": "https://opensource.org/licenses/MIT", - "owners": [ "hotchkj" ], "authors": [ "hotchkj" ], "version": "1.0.0-*", + "testRunner": "xunit", - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true }, - "commands": { - "integrate": "xunit.runner.dnx -parallel all" - }, - "dependencies": { - "AspNetCore.DataProtection.Aws.S3": "", - "AspNetCore.DataProtection.Aws.Kms": "", - "xunit": "2.1.0", - "Microsoft.Extensions.DependencyInjection": "1.0.0-rc1-final" + "AspNetCore.DataProtection.Aws.Kms": "1.0.0-*", + "AspNetCore.DataProtection.Aws.S3": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "Microsoft.Extensions.DependencyInjection": "1.0.0", + "xunit": "2.2.0-beta2-build3300" }, "frameworks": { - "dnx451": { + "net451": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Threading.Tasks": "4.0.0.0" + } + }, + "netcoreapp1.0": { "dependencies": { - "xunit.runner.dnx": "2.1.0-rc1-build204" + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } } } } diff --git a/src/AspNetCore.DataProtection.Aws.Kms/AspNetCore.DataProtection.Aws.Kms.xproj b/src/AspNetCore.DataProtection.Aws.Kms/AspNetCore.DataProtection.Aws.Kms.xproj index da3e11c..5208d45 100644 --- a/src/AspNetCore.DataProtection.Aws.Kms/AspNetCore.DataProtection.Aws.Kms.xproj +++ b/src/AspNetCore.DataProtection.Aws.Kms/AspNetCore.DataProtection.Aws.Kms.xproj @@ -4,15 +4,16 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 405c524a-e843-43eb-8164-60976e3a4df1 AspNetCore.DataProtection.Aws.Kms ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ + v4.5.1 2.0 - + \ No newline at end of file diff --git a/src/AspNetCore.DataProtection.Aws.Kms/DataProtectionBuilderExtensions.cs b/src/AspNetCore.DataProtection.Aws.Kms/DataProtectionBuilderExtensions.cs index 74ce6af..f103f3d 100644 --- a/src/AspNetCore.DataProtection.Aws.Kms/DataProtectionBuilderExtensions.cs +++ b/src/AspNetCore.DataProtection.Aws.Kms/DataProtectionBuilderExtensions.cs @@ -2,8 +2,8 @@ // Licensed under the MIT License. See License.md in the project root for license information. using Amazon.KeyManagementService; using Microsoft.Extensions.DependencyInjection; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.DataProtection.XmlEncryption; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.DataProtection.XmlEncryption; using System; namespace AspNetCore.DataProtection.Aws.Kms @@ -20,7 +20,7 @@ public static class DataProtectionBuilderExtensions /// KMS client configured with appropriate credentials. /// The configuration object specifying how use KMS keys. /// A reference to the after this operation has completed. - public static DataProtectionConfiguration ProtectKeysWithAwsKms(this DataProtectionConfiguration builder, IAmazonKeyManagementService kmsClient, KmsXmlEncryptorConfig config) + public static IDataProtectionBuilder ProtectKeysWithAwsKms(this IDataProtectionBuilder builder, IAmazonKeyManagementService kmsClient, KmsXmlEncryptorConfig config) { if (builder == null) { @@ -53,7 +53,7 @@ public static DataProtectionConfiguration ProtectKeysWithAwsKms(this DataProtect /// The . /// The configuration object specifying how use KMS keys. /// A reference to the after this operation has completed. - public static DataProtectionConfiguration ProtectKeysWithAwsKms(this DataProtectionConfiguration builder, KmsXmlEncryptorConfig config) + public static IDataProtectionBuilder ProtectKeysWithAwsKms(this IDataProtectionBuilder builder, KmsXmlEncryptorConfig config) { if (builder == null) { diff --git a/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlDecryptor.cs b/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlDecryptor.cs index 7b4e4d7..baaa0a5 100644 --- a/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlDecryptor.cs +++ b/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlDecryptor.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.md in the project root for license information. using Amazon.KeyManagementService; using Amazon.KeyManagementService.Model; -using Microsoft.AspNet.DataProtection.XmlEncryption; +using Microsoft.AspNetCore.DataProtection.XmlEncryption; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; diff --git a/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlEncryptor.cs b/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlEncryptor.cs index 35276a2..4fd676a 100644 --- a/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlEncryptor.cs +++ b/src/AspNetCore.DataProtection.Aws.Kms/KmsXmlEncryptor.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.md in the project root for license information. using Amazon.KeyManagementService; using Amazon.KeyManagementService.Model; -using Microsoft.AspNet.DataProtection.XmlEncryption; +using Microsoft.AspNetCore.DataProtection.XmlEncryption; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; diff --git a/src/AspNetCore.DataProtection.Aws.Kms/project.json b/src/AspNetCore.DataProtection.Aws.Kms/project.json index 9aae4b9..03deba6 100644 --- a/src/AspNetCore.DataProtection.Aws.Kms/project.json +++ b/src/AspNetCore.DataProtection.Aws.Kms/project.json @@ -1,25 +1,29 @@ { - "summary": "ASP.NET AWS KMS DataProtection Cryptography", - "description": "DataProtection encrypter & decrypter for use with AWS KMS (DNX RC1)", - "projectUrl": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws", - "licenseUrl": "https://opensource.org/licenses/MIT", - "repository": { - "type": "git", - "url": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws" - }, - "owners": [ "hotchkj" ], + "description": "DataProtection encrypter & decrypter for use with AWS KMS", "authors": [ "hotchkj" ], - "version": "1.0.0-alpha05", + "version": "1.0.0-beta01", + + "packOptions": { + "owners": [ "hotchkj" ], + "repository": { + "type": "git", + "url": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws" + }, + "summary": "ASP.NET AWS KMS DataProtection Cryptography", + "tags": [ "ASP.NET", "AWS", "DataProtection", "netcore" ], + "releaseNotes": "Updated to .NET Core", + "projectUrl": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws", + "licenseUrl": "https://opensource.org/licenses/MIT" + }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": false, - "warningsAsErrors": true, - "keyFile": "../../shared.snk" + "warningsAsErrors": true }, "dependencies": { - "AWSSDK.KeyManagementService": "3.1.2.2", - "Microsoft.AspNet.DataProtection": "1.0.0-rc1-final" + "AWSSDK.KeyManagementService": "3.2.5-beta", + "Microsoft.AspNetCore.DataProtection": "1.0.0" }, "frameworks": { @@ -27,7 +31,11 @@ "dependencies": { } }, - "dnx451": { + "netcore50": { + "dependencies": { + } + }, + "netstandard1.5": { "dependencies": { } } diff --git a/src/AspNetCore.DataProtection.Aws.S3/AspNetCore.DataProtection.Aws.S3.xproj b/src/AspNetCore.DataProtection.Aws.S3/AspNetCore.DataProtection.Aws.S3.xproj index 39a7888..170c21f 100644 --- a/src/AspNetCore.DataProtection.Aws.S3/AspNetCore.DataProtection.Aws.S3.xproj +++ b/src/AspNetCore.DataProtection.Aws.S3/AspNetCore.DataProtection.Aws.S3.xproj @@ -4,15 +4,16 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + a36a5d31-f6f5-4594-8326-1b5ff5877e8a AspNetCore.DataProtection.Aws.S3 ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ + v4.5.1 2.0 - + \ No newline at end of file diff --git a/src/AspNetCore.DataProtection.Aws.S3/DataProtectionBuilderExtensions.cs b/src/AspNetCore.DataProtection.Aws.S3/DataProtectionBuilderExtensions.cs index c4791fa..a45ab34 100644 --- a/src/AspNetCore.DataProtection.Aws.S3/DataProtectionBuilderExtensions.cs +++ b/src/AspNetCore.DataProtection.Aws.S3/DataProtectionBuilderExtensions.cs @@ -2,8 +2,8 @@ // Licensed under the MIT License. See License.md in the project root for license information. using System; using Microsoft.Extensions.DependencyInjection; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.DataProtection.Repositories; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.DataProtection.Repositories; using Amazon.S3; namespace AspNetCore.DataProtection.Aws.S3 @@ -20,7 +20,7 @@ public static class DataProtectionBuilderExtensions /// S3 client configured with appropriate credentials. /// The configuration object specifying how to write to S3. /// A reference to the after this operation has completed. - public static DataProtectionConfiguration PersistKeysToAwsS3(this DataProtectionConfiguration builder, IAmazonS3 s3Client, S3XmlRepositoryConfig config) + public static IDataProtectionBuilder PersistKeysToAwsS3(this IDataProtectionBuilder builder, IAmazonS3 s3Client, S3XmlRepositoryConfig config) { if (builder == null) { @@ -48,7 +48,7 @@ public static DataProtectionConfiguration PersistKeysToAwsS3(this DataProtection /// The . /// The configuration object specifying how to write to S3. /// A reference to the after this operation has completed. - public static DataProtectionConfiguration PersistKeysToAwsS3(this DataProtectionConfiguration builder, S3XmlRepositoryConfig config) + public static IDataProtectionBuilder PersistKeysToAwsS3(this IDataProtectionBuilder builder, S3XmlRepositoryConfig config) { if (builder == null) { diff --git a/src/AspNetCore.DataProtection.Aws.S3/S3XmlRepository.cs b/src/AspNetCore.DataProtection.Aws.S3/S3XmlRepository.cs index 6b4e742..12d436b 100644 --- a/src/AspNetCore.DataProtection.Aws.S3/S3XmlRepository.cs +++ b/src/AspNetCore.DataProtection.Aws.S3/S3XmlRepository.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.md in the project root for license information. using Amazon.S3; using Amazon.S3.Model; -using Microsoft.AspNet.DataProtection.Repositories; +using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; diff --git a/src/AspNetCore.DataProtection.Aws.S3/project.json b/src/AspNetCore.DataProtection.Aws.S3/project.json index efa9004..bf978e6 100644 --- a/src/AspNetCore.DataProtection.Aws.S3/project.json +++ b/src/AspNetCore.DataProtection.Aws.S3/project.json @@ -1,25 +1,29 @@ { - "summary": "ASP.NET AWS S3 DataProtection Repository", "description": "DataProtection repository for use with AWS S3 (DNX RC1)", - "projectUrl": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws", - "licenseUrl": "https://opensource.org/licenses/MIT", - "repository": { - "type": "git", - "url": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws" - }, - "owners": [ "hotchkj" ], "authors": [ "hotchkj" ], - "version": "1.0.0-alpha05", + "version": "1.0.0-beta01", + + "packOptions": { + "owners": [ "hotchkj" ], + "repository": { + "type": "git", + "url": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws" + }, + "summary": "ASP.NET AWS S3 DataProtection Repository", + "tags": [ "ASP.NET", "AWS", "DataProtection", "netcore" ], + "releaseNotes": "Updated to .NET Core", + "projectUrl": "https://github.com/hotchkj/AspNetCore.DataProtection.Aws", + "licenseUrl": "https://opensource.org/licenses/MIT" + }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": false, - "warningsAsErrors": true, - "keyFile": "../../shared.snk" + "warningsAsErrors": true }, "dependencies": { - "AWSSDK.S3": "3.1.7", - "Microsoft.AspNet.DataProtection": "1.0.0-rc1-final" + "AWSSDK.S3": "3.2.5-beta", + "Microsoft.AspNetCore.DataProtection": "1.0.0" }, "frameworks": { @@ -27,8 +31,14 @@ "dependencies": { } }, - "dnx451": { + "netcore50": { + "dependencies": { + "System.IO.Compression": "4.1.0" + } + }, + "netstandard1.5": { "dependencies": { + "System.IO.Compression": "4.1.0" } } } diff --git a/test/AspNetCore.DataProtection.Aws.Tests/AspNetCore.DataProtection.Aws.Tests.xproj b/test/AspNetCore.DataProtection.Aws.Tests/AspNetCore.DataProtection.Aws.Tests.xproj index e9efaf2..de92416 100644 --- a/test/AspNetCore.DataProtection.Aws.Tests/AspNetCore.DataProtection.Aws.Tests.xproj +++ b/test/AspNetCore.DataProtection.Aws.Tests/AspNetCore.DataProtection.Aws.Tests.xproj @@ -4,12 +4,12 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 37914c81-00e7-4fe5-887c-795e9de81463 - AspNetCore.DataProtection.Aws.IntegrationTests + AspNetCore.DataProtection.Aws.Tests ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ 2.0 @@ -17,5 +17,5 @@ - + \ No newline at end of file diff --git a/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlDecryptorTests.cs b/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlDecryptorTests.cs index 63aad0e..e8ee856 100644 --- a/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlDecryptorTests.cs +++ b/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlDecryptorTests.cs @@ -13,7 +13,7 @@ using System.Xml.Linq; using Xunit; -namespace AspNetCore.DataProtection.Aws.IntegrationTests +namespace AspNetCore.DataProtection.Aws.Tests { public class KmsXmlDecryptorTests : IDisposable { diff --git a/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlEncryptorTests.cs b/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlEncryptorTests.cs index 30552da..1641b88 100644 --- a/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlEncryptorTests.cs +++ b/test/AspNetCore.DataProtection.Aws.Tests/KmsXmlEncryptorTests.cs @@ -12,7 +12,7 @@ using System.Xml.Linq; using Xunit; -namespace AspNetCore.DataProtection.Aws.IntegrationTests +namespace AspNetCore.DataProtection.Aws.Tests { public class KmsXmlEncryptorTests : IDisposable { diff --git a/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryConfigTests.cs b/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryConfigTests.cs index bafe1cd..69327c4 100644 --- a/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryConfigTests.cs +++ b/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryConfigTests.cs @@ -4,7 +4,7 @@ using System; using Xunit; -namespace AspNetCore.DataProtection.Aws.IntegrationTests +namespace AspNetCore.DataProtection.Aws.Tests { public class S3XmlRepositoryConfigTests { diff --git a/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryTests.cs b/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryTests.cs index 7fcfe46..9a7bc9c 100644 --- a/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryTests.cs +++ b/test/AspNetCore.DataProtection.Aws.Tests/S3XmlRepositoryTests.cs @@ -13,7 +13,7 @@ using System.Xml.Linq; using Xunit; -namespace AspNetCore.DataProtection.Aws.IntegrationTests +namespace AspNetCore.DataProtection.Aws.Tests { public sealed class S3XmlRespositoryTests : IDisposable { diff --git a/test/AspNetCore.DataProtection.Aws.Tests/project.json b/test/AspNetCore.DataProtection.Aws.Tests/project.json index 70f0491..4227da7 100644 --- a/test/AspNetCore.DataProtection.Aws.Tests/project.json +++ b/test/AspNetCore.DataProtection.Aws.Tests/project.json @@ -1,29 +1,25 @@ { - "summary": "ASP.NET DataProtection Repository Integration Tests", - "licenseUrl": "https://opensource.org/licenses/MIT", - "owners": [ "hotchkj" ], "authors": [ "hotchkj" ], "version": "1.0.0-*", + "testRunner": "xunit", - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true }, - "commands": { - "test": "xunit.runner.dnx -parallel all" - }, - "dependencies": { - "AspNetCore.DataProtection.Aws.Kms": "", - "AspNetCore.DataProtection.Aws.S3": "", - "Moq": "4.5.8", - "xunit": "2.1.0" + "AspNetCore.DataProtection.Aws.Kms": "1.0.0-*", + "AspNetCore.DataProtection.Aws.S3": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "xunit": "2.2.0-beta2-build3300" }, "frameworks": { - "dnx451": { + "net451": { "dependencies": { - "xunit.runner.dnx": "2.1.0-rc1-build204" + "Microsoft.NETCore.Platforms": "1.0.1", + "Moq": "4.5.8", + "System.Threading.Tasks": "4.0.0.0" } } } From 86ec4af4b90f4f588f0b57dfedcf6adc819f701f Mon Sep 17 00:00:00 2001 From: hotchkj Date: Sat, 2 Jul 2016 18:13:50 +0100 Subject: [PATCH 2/4] Removing netcore app from integration tests enables VS to find them, so this suggests the VS NetCore tooling isn't quite ready yet Closes issue #1. Tests are purely NET Framework until xUnit, VS, and NetCore tooling comes out of beta. --- .../project.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json index 44eec62..707fecd 100644 --- a/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json +++ b/integrate/AspNetCore.DataProtection.Aws.IntegrationTests/project.json @@ -21,14 +21,6 @@ "Microsoft.NETCore.Platforms": "1.0.1", "System.Threading.Tasks": "4.0.0.0" } - }, - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - } } } } \ No newline at end of file From dab007289a4840bdd61f7c260a04edb5db320f6b Mon Sep 17 00:00:00 2001 From: hotchkj Date: Sat, 2 Jul 2016 19:48:59 +0100 Subject: [PATCH 3/4] Fixes description, restores deprecated owners entry as current NuGet tooling doesn't pick up the new one yet --- src/AspNetCore.DataProtection.Aws.Kms/project.json | 3 ++- src/AspNetCore.DataProtection.Aws.S3/project.json | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AspNetCore.DataProtection.Aws.Kms/project.json b/src/AspNetCore.DataProtection.Aws.Kms/project.json index 03deba6..3bd88ac 100644 --- a/src/AspNetCore.DataProtection.Aws.Kms/project.json +++ b/src/AspNetCore.DataProtection.Aws.Kms/project.json @@ -1,7 +1,8 @@ { "description": "DataProtection encrypter & decrypter for use with AWS KMS", - "authors": [ "hotchkj" ], "version": "1.0.0-beta01", + "authors": [ "hotchkj" ], + "owners": [ "hotchkj" ], "packOptions": { "owners": [ "hotchkj" ], diff --git a/src/AspNetCore.DataProtection.Aws.S3/project.json b/src/AspNetCore.DataProtection.Aws.S3/project.json index bf978e6..138b7db 100644 --- a/src/AspNetCore.DataProtection.Aws.S3/project.json +++ b/src/AspNetCore.DataProtection.Aws.S3/project.json @@ -1,7 +1,8 @@ { - "description": "DataProtection repository for use with AWS S3 (DNX RC1)", - "authors": [ "hotchkj" ], + "description": "DataProtection repository for use with AWS S3", "version": "1.0.0-beta01", + "authors": [ "hotchkj" ], + "owners": [ "hotchkj" ], "packOptions": { "owners": [ "hotchkj" ], From 5545c302a282392398991a40f69137501446603b Mon Sep 17 00:00:00 2001 From: hotchkj Date: Sat, 2 Jul 2016 20:18:19 +0100 Subject: [PATCH 4/4] Update README.md documentation to new NET Core style --- README.md | 57 +++++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d9c0394..30081e5 100644 --- a/README.md +++ b/README.md @@ -16,28 +16,25 @@ In Startup.cs, specified as part of DataProtection configuration: ```csharp public void ConfigureServices(IServiceCollection services) { - services.AddDataProtection(); - services.ConfigureDataProtection(configure => - { - configure.PersistKeysToAwsS3(new AmazonS3Client(), new S3XmlRepositoryConfig("my-bucket-name") - // Configuration has defaults; all below are optional - { - // How many concurrent connections will be made to S3 to retrieve key data - MaxS3QueryConcurrency = 10, - // Custom prefix in the S3 bucket enabling use of folders - KeyPrefix = "MyKeys/", - // Customise storage class for key storage - StorageClass = S3StorageClass.Standard, - // Customise encryption options (these can be mutually exclusive - don't just copy & paste!) - ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256, - ServerSideEncryptionCustomerMethod = ServerSideEncryptionCustomerMethod.AES256, - ServerSideEncryptionCustomerProvidedKey = "MyBase64Key", - ServerSideEncryptionCustomerProvidedKeyMD5 = "MD5OfMyBase64Key", - ServerSideEncryptionKeyManagementServiceKeyId = "AwsKeyManagementServiceId", - // Compress stored XML before write to S3 - ClientSideCompression = true - }); - }); + services.AddDataProtection() + .PersistKeysToAwsS3(new AmazonS3Client(), new S3XmlRepositoryConfig("my-bucket-name") + // Configuration has defaults; all below are optional + { + // How many concurrent connections will be made to S3 to retrieve key data + MaxS3QueryConcurrency = 10, + // Custom prefix in the S3 bucket enabling use of folders + KeyPrefix = "MyKeys/", + // Customise storage class for key storage + StorageClass = S3StorageClass.Standard, + // Customise encryption options (these can be mutually exclusive - don't just copy & paste!) + ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256, + ServerSideEncryptionCustomerMethod = ServerSideEncryptionCustomerMethod.AES256, + ServerSideEncryptionCustomerProvidedKey = "MyBase64Key", + ServerSideEncryptionCustomerProvidedKeyMD5 = "MD5OfMyBase64Key", + ServerSideEncryptionKeyManagementServiceKeyId = "AwsKeyManagementServiceId", + // Compress stored XML before write to S3 + ClientSideCompression = true + }); } ``` If the `IAmazonS3` interface is discoverable via Dependency Injection in `IServiceCollection`, the constructor argument of `AmazonS3Client` can be omitted. @@ -54,15 +51,13 @@ In Startup.cs, specified as part of DataProtection configuration: ```csharp public void ConfigureServices(IServiceCollection services) { - services.AddDataProtection(); - services.ConfigureDataProtection(configure => - { - var kmsConfig = new KmsXmlEncryptorConfig("my-application-name", "alias/MyKmsAlias"); - // Configuration has default contexts added; below are optional if using grants or additional contexts - kmsConfig.EncryptionContext.Add("my-custom-context", "my-custom-value"); - kmsConfig.GrantTokens.Add("my-grant-token"); - configure.ProtectKeysWithAwsKms(new AmazonKeyManagementServiceClient(), kmsConfig); - }); + var kmsConfig = new KmsXmlEncryptorConfig("my-application-name", "alias/MyKmsAlias"); + // Configuration has default contexts added; below are optional if using grants or additional contexts + kmsConfig.EncryptionContext.Add("my-custom-context", "my-custom-value"); + kmsConfig.GrantTokens.Add("my-grant-token"); + + services.AddDataProtection() + .ProtectKeysWithAwsKms(new AmazonKeyManagementServiceClient(), kmsConfig); } ``` If the `IAmazonKeyManagementService` interface is discoverable via Dependency Injection in `IServiceCollection`, the constructor argument of `AmazonKeyManagementServiceClient` can be omitted. \ No newline at end of file