Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Extensions] Update DataProtection dependency to v8.x #47286

Merged
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
@@ -1,15 +1,12 @@
# Release History

## 1.4.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed
## 1.4.0 (2024-11-26)

### Other Changes

- Updated dependency `Microsoft.Extensions.DependencyInjection` to version `8.0.11`
- Updated dependency `Microsoft.Bcl.AsyncInterfaces` to version `8.0.0`

## 1.3.4 (2024-04-16)

### Bugs Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<Description>Microsoft Azure Blob storage support as key store (https://docs.microsoft.com/aspnet/core/security/data-protection/implementation/key-storage-providers).</Description>
<PackageTags>aspnetcore;dataprotection;azure;blob;key store</PackageTags>
<Version>1.4.0-beta.1</Version>
<Version>1.4.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.3.4</ApiCompatVersion>
<IsExtensionClientLibrary>true</IsExtensionClientLibrary>
Expand All @@ -13,7 +13,8 @@

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" VersionOverride="8.0.11" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" VersionOverride="8.0.0" />
<PackageReference Include="Azure.Storage.Blobs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" VersionOverride="8.0.1" />
<PackageReference Include="Moq" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Release History

## 1.3.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed
## 1.3.0 (2024-11-26)

### Other Changes

- Updated dependency `Microsoft.Extensions.DependencyInjection` to version `8.0.11`
- Updated dependency `Microsoft.Bcl.AsyncInterfaces` to version `8.0.0`

## 1.2.4 (2024-08-16)

### Other Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Microsoft Azure Key Vault key encryption support.</Description>
<PackageTags>aspnetcore;dataprotection;azure;keyvault</PackageTags>
<Version>1.3.0-beta.1</Version>
<Version>1.3.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.2.4</ApiCompatVersion>
<IsExtensionClientLibrary>true</IsExtensionClientLibrary>
Expand All @@ -12,7 +12,8 @@

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" VersionOverride="8.0.11" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" VersionOverride="8.0.0" />
<PackageReference Include="Azure.Security.KeyVault.Keys" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
Expand All @@ -9,10 +9,8 @@
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" VersionOverride="8.0.1" />
<PackageReference Include="Moq" />

<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureKeyVault" VersionOverride="3.1.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using Azure.Identity;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.Azure.KeyVault;
using Azure.Security.KeyVault.Keys;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Azure.Core.TestFramework;

namespace Azure.Extensions.AspNetCore.DataProtection.Keys.Tests
{
Expand All @@ -19,7 +20,7 @@ public class AzureDataProtectionBuilderExtensionsTests
public void ProtectKeysWithAzureKeyVault_UsesAzureKeyVaultXmlEncryptor()
{
// Arrange
var client = new KeyVaultClient((_, _, _) => Task.FromResult(string.Empty));
var client = new KeyClient(new Uri("http://www.example.com/dummyKey"),new MockCredential());
var serviceCollection = new ServiceCollection();
var builder = serviceCollection.AddDataProtection();

Expand All @@ -36,7 +37,7 @@ public void ProtectKeysWithAzureKeyVault_UsesAzureKeyVaultXmlEncryptor()
public void ProtectKeysWithAzureKeyVault_WithServiceProviderFunc_UsesAzureKeyVaultXmlEncryptor()
{
// Arrange
var client = new KeyVaultClient((_, _, _) => Task.FromResult(string.Empty));
var client = new KeyClient(new Uri("http://www.example.com/dummyKey"), new MockCredential());
var serviceCollection = new ServiceCollection();
var builder = serviceCollection.AddDataProtection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using System.Threading.Tasks;
using System.Xml.Linq;
using Azure.Core.TestFramework;
using Azure.Extensions.AspNetCore.DataProtection.Keys.Tests;
using Azure.Identity;
using Azure.Security.KeyVault.Keys;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
Expand Down Expand Up @@ -56,7 +54,7 @@ public async Task ProtectsKeysWithKeyVaultKey()
}

[Test]
public async Task CanUprotectExistingKeys()
public async Task CanDecryptEncryptedKeys()
{
var client = new KeyClient(new Uri(TestEnvironment.KeyVaultUrl), TestEnvironment.Credential);
var key = await client.CreateKeyAsync("TestEncryptionKey2", KeyType.Rsa);
Expand All @@ -65,32 +63,23 @@ public async Task CanUprotectExistingKeys()

var testKeyRepository = new TestKeyRepository();

AzureDataProtectionBuilderExtensions.ProtectKeysWithAzureKeyVault(
serviceCollection.AddDataProtection(),
key.Value.Id.AbsoluteUri,
TestEnvironment.ClientId,
TestEnvironment.ClientSecret);
// Configure data protection to use TokenCredential
serviceCollection.AddDataProtection()
.ProtectKeysWithAzureKeyVault(key.Value.Id, TestEnvironment.Credential);

serviceCollection.Configure<KeyManagementOptions>(options =>
{
options.XmlRepository = testKeyRepository;
});

var servicesOld = serviceCollection.BuildServiceProvider();

var serviceCollectionNew = new ServiceCollection();
serviceCollectionNew.AddDataProtection().ProtectKeysWithAzureKeyVault(key.Value.Id, TestEnvironment.Credential);
serviceCollectionNew.Configure<KeyManagementOptions>(options =>
{
options.XmlRepository = testKeyRepository;
});
var services = serviceCollection.BuildServiceProvider();

var dataProtector = servicesOld.GetService<IDataProtectionProvider>().CreateProtector("Fancy purpose");
// Encrypt data
var dataProtector = services.GetService<IDataProtectionProvider>().CreateProtector("Fancy purpose");
var protectedText = dataProtector.Protect("Hello world!");

var newServices = serviceCollectionNew.BuildServiceProvider();
var newDataProtectionProvider = newServices.GetService<IDataProtectionProvider>().CreateProtector("Fancy purpose");
var unprotectedText = newDataProtectionProvider.Unprotect(protectedText);
// Decrypt data
var unprotectedText = dataProtector.Unprotect(protectedText);

Assert.AreEqual("Hello world!", unprotectedText);

Expand Down
11 changes: 4 additions & 7 deletions sdk/extensions/Microsoft.Extensions.Azure/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Release History

## 1.9.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed
## 1.9.0 (2024-11-26)

### Other Changes

- Updated dependency `Microsoft.Extensions.DependencyInjection.Abstractions` to version `8.0.2`
- Updated dependency `Microsoft.Bcl.AsyncInterfaces` to version `8.0.0`

## 1.8.0 (2024-11-05)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<Description>Azure Client SDK integration with Microsoft.Extensions libraries</Description>
<AssemblyTitle>Azure Client SDK integration Microsoft.Extensions</AssemblyTitle>
<Version>1.9.0-beta.1</Version>
<Version>1.9.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>1.8.0</ApiCompatVersion>
<PackageTags>Microsoft Azure Client Pipeline AspNetCore Extensions</PackageTags>
Expand All @@ -21,10 +21,11 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" VersionOverride="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" VersionOverride="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" VersionOverride="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Net.WebSockets.Client" />
<PackageReference Include="System.ValueTuple" />
Expand Down