From 1874aebf98d6e4534a10de67e92a8d8c1541c02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20C=C3=A1rdenas?= Date: Tue, 26 Nov 2024 16:26:16 -0700 Subject: [PATCH] [Extensions] Update DataProtection dependency to v8.x (#47286) * Bump Microsoft.AspNetCore.DataProtection to 8.0.11 * Bump Microsoft.Extensions.DependencyInjection to 6.0.2 * Bump Microsoft.Extensions.DependencyInjection.Abstractions to 8.0.2 * Upgrade Microsoft.Extensions.DependencyInjection to 8.0.1 * Remove dependency on Microsoft.AspNetCore.DataProtection.AzureKeyVault * Update CanDecryptEncryptedKeys test * Fix tests using track1 KeyVault SDK * Override version for Microsoft.Bcl.AsyncInterfaces * Override Microsoft.Bcl.AsyncInterfaces to v8.0.0 * Override DependencyInjections and DataProtections versions in Extensions * Revert changes in Packages.Data.Props * Override versions in Microsoft.Extensions.Azure and add AsyncInterfaces back * Update changelogs and project versions --- .../CHANGELOG.md | 11 +++---- ...ons.AspNetCore.DataProtection.Blobs.csproj | 5 ++-- ...pNetCore.DataProtection.Blobs.Tests.csproj | 2 +- .../CHANGELOG.md | 11 +++---- ...ions.AspNetCore.DataProtection.Keys.csproj | 5 ++-- ...spNetCore.DataProtection.Keys.Tests.csproj | 6 ++-- ...ureDataProtectionBuilderExtensionsTests.cs | 7 +++-- .../DataProtectionKeysFunctionalTests.cs | 29 ++++++------------- .../Microsoft.Extensions.Azure/CHANGELOG.md | 11 +++---- .../src/Microsoft.Extensions.Azure.csproj | 5 ++-- .../Microsoft.Extensions.Azure.Tests.csproj | 2 +- 11 files changed, 38 insertions(+), 56 deletions(-) diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/CHANGELOG.md b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/CHANGELOG.md index 33836ed05e8a3..d6604fecf8bc5 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/CHANGELOG.md +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/CHANGELOG.md @@ -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 diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/src/Azure.Extensions.AspNetCore.DataProtection.Blobs.csproj b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/src/Azure.Extensions.AspNetCore.DataProtection.Blobs.csproj index 1cfd1f82d261d..6df24736d4bd9 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/src/Azure.Extensions.AspNetCore.DataProtection.Blobs.csproj +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/src/Azure.Extensions.AspNetCore.DataProtection.Blobs.csproj @@ -4,7 +4,7 @@ $(RequiredTargetFrameworks) Microsoft Azure Blob storage support as key store (https://docs.microsoft.com/aspnet/core/security/data-protection/implementation/key-storage-providers). aspnetcore;dataprotection;azure;blob;key store - 1.4.0-beta.1 + 1.4.0 1.3.4 true @@ -13,7 +13,8 @@ - + + diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/tests/Azure.Extensions.AspNetCore.DataProtection.Blobs.Tests.csproj b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/tests/Azure.Extensions.AspNetCore.DataProtection.Blobs.Tests.csproj index aa0712d7c775d..2d7248bb29b7c 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/tests/Azure.Extensions.AspNetCore.DataProtection.Blobs.Tests.csproj +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Blobs/tests/Azure.Extensions.AspNetCore.DataProtection.Blobs.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/CHANGELOG.md b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/CHANGELOG.md index c0256e41a418d..ff357993ca00e 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/CHANGELOG.md +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/CHANGELOG.md @@ -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 diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/src/Azure.Extensions.AspNetCore.DataProtection.Keys.csproj b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/src/Azure.Extensions.AspNetCore.DataProtection.Keys.csproj index 66cd07e27c480..9b19732b79b4b 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/src/Azure.Extensions.AspNetCore.DataProtection.Keys.csproj +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/src/Azure.Extensions.AspNetCore.DataProtection.Keys.csproj @@ -3,7 +3,7 @@ Microsoft Azure Key Vault key encryption support. aspnetcore;dataprotection;azure;keyvault - 1.3.0-beta.1 + 1.3.0 1.2.4 true @@ -12,7 +12,8 @@ - + + diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/Azure.Extensions.AspNetCore.DataProtection.Keys.Tests.csproj b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/Azure.Extensions.AspNetCore.DataProtection.Keys.Tests.csproj index 802348cb19eb2..67bcd63e9f5d0 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/Azure.Extensions.AspNetCore.DataProtection.Keys.Tests.csproj +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/Azure.Extensions.AspNetCore.DataProtection.Keys.Tests.csproj @@ -1,4 +1,4 @@ - + $(RequiredTargetFrameworks) @@ -9,10 +9,8 @@ - + - - diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/AzureDataProtectionBuilderExtensionsTests.cs b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/AzureDataProtectionBuilderExtensionsTests.cs index 8fa5e8d1a2890..bc79a4e469412 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/AzureDataProtectionBuilderExtensionsTests.cs +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/AzureDataProtectionBuilderExtensionsTests.cs @@ -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 { @@ -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(); @@ -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(); diff --git a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/DataProtectionKeysFunctionalTests.cs b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/DataProtectionKeysFunctionalTests.cs index aebf269228ae8..5cbc76c99d122 100644 --- a/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/DataProtectionKeysFunctionalTests.cs +++ b/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/tests/DataProtectionKeysFunctionalTests.cs @@ -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; @@ -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); @@ -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(options => { options.XmlRepository = testKeyRepository; }); - var servicesOld = serviceCollection.BuildServiceProvider(); - - var serviceCollectionNew = new ServiceCollection(); - serviceCollectionNew.AddDataProtection().ProtectKeysWithAzureKeyVault(key.Value.Id, TestEnvironment.Credential); - serviceCollectionNew.Configure(options => - { - options.XmlRepository = testKeyRepository; - }); + var services = serviceCollection.BuildServiceProvider(); - var dataProtector = servicesOld.GetService().CreateProtector("Fancy purpose"); + // Encrypt data + var dataProtector = services.GetService().CreateProtector("Fancy purpose"); var protectedText = dataProtector.Protect("Hello world!"); - var newServices = serviceCollectionNew.BuildServiceProvider(); - var newDataProtectionProvider = newServices.GetService().CreateProtector("Fancy purpose"); - var unprotectedText = newDataProtectionProvider.Unprotect(protectedText); + // Decrypt data + var unprotectedText = dataProtector.Unprotect(protectedText); Assert.AreEqual("Hello world!", unprotectedText); diff --git a/sdk/extensions/Microsoft.Extensions.Azure/CHANGELOG.md b/sdk/extensions/Microsoft.Extensions.Azure/CHANGELOG.md index 37be1d9b3dca6..cd3fbba48265b 100644 --- a/sdk/extensions/Microsoft.Extensions.Azure/CHANGELOG.md +++ b/sdk/extensions/Microsoft.Extensions.Azure/CHANGELOG.md @@ -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 diff --git a/sdk/extensions/Microsoft.Extensions.Azure/src/Microsoft.Extensions.Azure.csproj b/sdk/extensions/Microsoft.Extensions.Azure/src/Microsoft.Extensions.Azure.csproj index f376226b86472..fd3d1eb1ac6a1 100644 --- a/sdk/extensions/Microsoft.Extensions.Azure/src/Microsoft.Extensions.Azure.csproj +++ b/sdk/extensions/Microsoft.Extensions.Azure/src/Microsoft.Extensions.Azure.csproj @@ -4,7 +4,7 @@ $(RequiredTargetFrameworks) Azure Client SDK integration with Microsoft.Extensions libraries Azure Client SDK integration Microsoft.Extensions - 1.9.0-beta.1 + 1.9.0 1.8.0 Microsoft Azure Client Pipeline AspNetCore Extensions @@ -21,10 +21,11 @@ - + + diff --git a/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj b/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj index d02d3a6ad2ac7..39136ce31ab43 100644 --- a/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj +++ b/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj @@ -4,7 +4,7 @@ - +