Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 from hotchkj/netcore-rtm
Browse files Browse the repository at this point in the history
.NET Core RTM build
  • Loading branch information
hotchkj authored Jul 2, 2016
2 parents 6363448 + 5545c30 commit abfef87
Show file tree
Hide file tree
Showing 24 changed files with 160 additions and 172 deletions.
2 changes: 1 addition & 1 deletion AspNetCore.DataProtection.Aws.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
57 changes: 26 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
5 changes: 1 addition & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-final"
}
"projects": [ "src", "test", "integrate" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>d19ebbf5-fa0e-4ec5-a11f-9b5ac1165b39</ProjectGuid>
<RootNamespace>AspNetCore.DataProtection.Aws.IntegrationTests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IXmlRepository>(),
Expand All @@ -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<IXmlRepository>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IXmlRepository>(new EphemeralXmlRepository());
serviceCollection.AddDataProtection()
.ProtectKeysWithAwsKms(kmsClient, config);
serviceCollection.AddSingleton<IXmlRepository, EphemeralXmlRepository>();
var serviceProvider = serviceCollection.BuildServiceProvider();

var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService<IXmlRepository>(),
Expand All @@ -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<IXmlRepository>(new EphemeralXmlRepository());
serviceCollection.AddSingleton(kmsClient);
serviceCollection.AddDataProtection()
.ProtectKeysWithAwsKms(config);
serviceCollection.AddSingleton<IXmlRepository, EphemeralXmlRepository>();
var serviceProvider = serviceCollection.BuildServiceProvider();

var keyManager = new XmlKeyManager(serviceProvider.GetRequiredService<IXmlRepository>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IXmlRepository>(),
Expand All @@ -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<IXmlRepository>(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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": {
"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": {
"xunit.runner.dnx": "2.1.0-rc1-build204"
"Microsoft.NETCore.Platforms": "1.0.1",
"System.Threading.Tasks": "4.0.0.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>405c524a-e843-43eb-8164-60976e3a4df1</ProjectGuid>
<RootNamespace>AspNetCore.DataProtection.Aws.Kms</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@ public static class DataProtectionBuilderExtensions
/// <param name="kmsClient">KMS client configured with appropriate credentials.</param>
/// <param name="config">The configuration object specifying how use KMS keys.</param>
/// <returns>A reference to the <see cref="DataProtectionConfiguration" /> after this operation has completed.</returns>
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)
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public static DataProtectionConfiguration ProtectKeysWithAwsKms(this DataProtect
/// <param name="builder">The <see cref="DataProtectionConfiguration"/>.</param>
/// <param name="config">The configuration object specifying how use KMS keys.</param>
/// <returns>A reference to the <see cref="DataProtectionConfiguration" /> after this operation has completed.</returns>
public static DataProtectionConfiguration ProtectKeysWithAwsKms(this DataProtectionConfiguration builder, KmsXmlEncryptorConfig config)
public static IDataProtectionBuilder ProtectKeysWithAwsKms(this IDataProtectionBuilder builder, KmsXmlEncryptorConfig config)
{
if (builder == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCore.DataProtection.Aws.Kms/KmsXmlDecryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCore.DataProtection.Aws.Kms/KmsXmlEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit abfef87

Please sign in to comment.