Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.0.0-preview.2 (Unreleased)

- Package renamed to Azure.Extensions.AspNetCore.DataProtection.Keys
- Default overload of ProtectKeysWithAzureKeyVault now takes a Uri to be consistent with other extension methods and KeyVault clients.

## 1.0.0-preview.1 (2020)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void ConfigureServices(IServiceCollection services)
{
services
.AddDataProtection()
.ProtectKeysWithAzureKeyVault("<Key-ID>", new DefaultAzureCredential());
.ProtectKeysWithAzureKeyVault(new Uri("<Key-ID>"), new DefaultAzureCredential());
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Microsoft.AspNetCore.DataProtection
public static partial class AzureDataProtectionKeyVaultKeyBuilderExtensions
{
public static Microsoft.AspNetCore.DataProtection.IDataProtectionBuilder ProtectKeysWithAzureKeyVault(this Microsoft.AspNetCore.DataProtection.IDataProtectionBuilder builder, string keyIdentifier, Azure.Core.Cryptography.IKeyEncryptionKeyResolver keyResolver) { throw null; }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is an advanced scenario that requires string because IKeyEncryptionKeyResolver is string based.

public static Microsoft.AspNetCore.DataProtection.IDataProtectionBuilder ProtectKeysWithAzureKeyVault(this Microsoft.AspNetCore.DataProtection.IDataProtectionBuilder builder, string keyIdentifier, Azure.Core.TokenCredential tokenCredential) { throw null; }
public static Microsoft.AspNetCore.DataProtection.IDataProtectionBuilder ProtectKeysWithAzureKeyVault(this Microsoft.AspNetCore.DataProtection.IDataProtectionBuilder builder, System.Uri keyIdentifier, Azure.Core.TokenCredential tokenCredential) { throw null; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Extensions.AspNetCore.DataProtection.Keys;
using Azure.Core;
using Azure.Core.Cryptography;
Expand All @@ -24,9 +25,10 @@ public static class AzureDataProtectionKeyVaultKeyBuilderExtensions
/// <param name="keyIdentifier">The Azure Key Vault key identifier used for key encryption.</param>
/// <param name="tokenCredential">The token credential to use for authentication.</param>
/// <returns>The value <paramref name="builder"/>.</returns>
public static IDataProtectionBuilder ProtectKeysWithAzureKeyVault(this IDataProtectionBuilder builder, string keyIdentifier, TokenCredential tokenCredential)
public static IDataProtectionBuilder ProtectKeysWithAzureKeyVault(this IDataProtectionBuilder builder, Uri keyIdentifier, TokenCredential tokenCredential)
{
return ProtectKeysWithAzureKeyVault(builder, keyIdentifier, new KeyResolver(tokenCredential));
Argument.AssertNotNull(keyIdentifier, nameof(keyIdentifier));
return ProtectKeysWithAzureKeyVault(builder, keyIdentifier.ToString(), new KeyResolver(tokenCredential));
Comment thread
pakrym marked this conversation as resolved.
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task ProtectsKeysWithKeyVaultKey()

var testKeyRepository = new TestKeyRepository();

serviceCollection.AddDataProtection().ProtectKeysWithAzureKeyVault(key.Value.Id.ToString(), credential);
serviceCollection.AddDataProtection().ProtectKeysWithAzureKeyVault(key.Value.Id, credential);

serviceCollection.Configure<KeyManagementOptions>(options =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ConfigureServices(IServiceCollection services)
{
services
.AddDataProtection()
.ProtectKeysWithAzureKeyVault("<Key-ID>", new DefaultAzureCredential());
.ProtectKeysWithAzureKeyVault(new Uri("<Key-ID>"), new DefaultAzureCredential());
}
#endregion
}
Expand Down