From 2c49118f833fd50d9ba01cc4bbb672aff05f830b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 2 Nov 2026 13:07:32 +0100 Subject: [PATCH] Replace DecompressionMethods.All by ~DecompressionMethods.None --- .../OpenIddict.Extensions/OpenIddictPolyfills.cs | 14 -------------- .../OpenIddictClientSystemNetHttpHandlers.cs | 2 +- .../OpenIddictClientSystemNetHttpOptions.cs | 2 +- .../OpenIddictValidationSystemNetHttpHandlers.cs | 2 +- .../OpenIddictValidationSystemNetHttpOptions.cs | 2 +- .../OpenIddictClientSystemNetHttpBuilderTests.cs | 4 ++-- .../OpenIddictClientSystemNetHttpHandlersTests.cs | 4 ++-- ...penIddictValidationSystemNetHttpBuilderTests.cs | 4 ++-- ...enIddictValidationSystemNetHttpHandlersTests.cs | 4 ++-- 9 files changed, 12 insertions(+), 26 deletions(-) diff --git a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs index 1245f7ad..4030b262 100644 --- a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs +++ b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs @@ -72,20 +72,6 @@ internal static class OpenIddictPolyfills #endif } - extension(DecompressionMethods) - { -#if !NET - /// - /// Use all compression-decompression algorithms. - /// - /// - /// Note: the backing value (-1) is identical to the one used by the - /// DecompressionMethods.All member exposed by .NET Core 2.1 and higher. - /// - public static DecompressionMethods All => (DecompressionMethods) (-1); -#endif - } - extension(HMACSHA256) { #if !NET diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs index 780754d9..bf230764 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs @@ -615,7 +615,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers // Note: the algorithms that were not explicitly allowed are rejected even if they are natively // supported by the runtime (e.g to prevent using a decoder affected by a known vulnerability). // - // DecompressionMethods.All (whose backing value is -1) has all the bits set and can be + // ~DecompressionMethods.None (which is equivalent to .All) has all the bits set and can be // used to bypass the individual checks and allow all the algorithms supported by OpenIddict. var methods = _options.CurrentValue.AllowedDecompressionMethods; diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs index ec4c5f0d..c9162bfd 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs @@ -89,7 +89,7 @@ public sealed class OpenIddictClientSystemNetHttpOptions /// algorithms (e.g to mitigate a vulnerability affecting one of the decoders used by the runtime). /// By default, all the algorithms supported by OpenIddict are allowed. /// - public DecompressionMethods AllowedDecompressionMethods { get; set; } = DecompressionMethods.All; + public DecompressionMethods AllowedDecompressionMethods { get; set; } = ~DecompressionMethods.None; /// /// Gets the user-defined actions used to amend the diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs index 712407ff..09e248aa 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs @@ -611,7 +611,7 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers // Note: the algorithms that were not explicitly allowed are rejected even if they are natively // supported by the runtime (e.g to prevent using a decoder affected by a known vulnerability). // - // DecompressionMethods.All (whose backing value is -1) has all the bits set and can be + // ~DecompressionMethods.None (which is equivalent to .All) has all the bits set and can be // used to bypass the individual checks and allow all the algorithms supported by OpenIddict. var methods = _options.CurrentValue.AllowedDecompressionMethods; diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs index dfd85777..a9913568 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs @@ -89,7 +89,7 @@ public sealed class OpenIddictValidationSystemNetHttpOptions /// algorithms (e.g to mitigate a vulnerability affecting one of the decoders used by the runtime). /// By default, all the algorithms supported by OpenIddict are allowed. /// - public DecompressionMethods AllowedDecompressionMethods { get; set; } = DecompressionMethods.All; + public DecompressionMethods AllowedDecompressionMethods { get; set; } = ~DecompressionMethods.None; /// /// Gets the user-defined actions used to amend the diff --git a/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpBuilderTests.cs b/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpBuilderTests.cs index 5bc9a184..79e9dee0 100644 --- a/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpBuilderTests.cs +++ b/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpBuilderTests.cs @@ -66,7 +66,7 @@ public class OpenIddictClientSystemNetHttpBuilderTests var options = GetOptions(services); // Assert - Assert.Equal(DecompressionMethods.All, options.AllowedDecompressionMethods); + Assert.Equal(~DecompressionMethods.None, options.AllowedDecompressionMethods); } [Theory] @@ -78,7 +78,7 @@ public class OpenIddictClientSystemNetHttpBuilderTests [InlineData(DecompressionMethods.Brotli)] [InlineData(DecompressionMethods.GZip | DecompressionMethods.Brotli)] [InlineData(DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli)] - [InlineData(DecompressionMethods.All)] + [InlineData(~DecompressionMethods.None)] #endif public void SetAllowedDecompressionMethods_SetsAllowedDecompressionMethods(DecompressionMethods methods) { diff --git a/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpHandlersTests.cs b/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpHandlersTests.cs index 9a7e5607..04e0a1e6 100644 --- a/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpHandlersTests.cs +++ b/test/OpenIddict.Client.SystemNetHttp.Tests/OpenIddictClientSystemNetHttpHandlersTests.cs @@ -85,13 +85,13 @@ public class OpenIddictClientSystemNetHttpHandlersTests var context = new PrepareDeviceAuthorizationRequestContext( CreateTransaction(Mock.Of>(), response)); var handler = new DecompressResponseContent( - CreateOptions(DecompressionMethods.All)); + CreateOptions(~DecompressionMethods.None)); // Act await handler.HandleAsync(context); // Assert - Assert.True(DecompressionMethods.All.HasFlag(method)); + Assert.True((~DecompressionMethods.None).HasFlag(method)); Assert.False(context.IsRejected); Assert.Empty(response.Content.Headers.ContentEncoding); Assert.Equal(Payload, await response.Content.ReadAsStringAsync()); diff --git a/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpBuilderTests.cs b/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpBuilderTests.cs index 74cccedc..defcd8b1 100644 --- a/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpBuilderTests.cs +++ b/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpBuilderTests.cs @@ -66,7 +66,7 @@ public class OpenIddictValidationSystemNetHttpBuilderTests var options = GetOptions(services); // Assert - Assert.Equal(DecompressionMethods.All, options.AllowedDecompressionMethods); + Assert.Equal(~DecompressionMethods.None, options.AllowedDecompressionMethods); } [Theory] @@ -78,7 +78,7 @@ public class OpenIddictValidationSystemNetHttpBuilderTests [InlineData(DecompressionMethods.Brotli)] [InlineData(DecompressionMethods.GZip | DecompressionMethods.Brotli)] [InlineData(DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli)] - [InlineData(DecompressionMethods.All)] + [InlineData(~DecompressionMethods.None)] #endif public void SetAllowedDecompressionMethods_SetsAllowedDecompressionMethods(DecompressionMethods methods) { diff --git a/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpHandlersTests.cs b/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpHandlersTests.cs index a45034a2..8ce4d82f 100644 --- a/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpHandlersTests.cs +++ b/test/OpenIddict.Validation.SystemNetHttp.Tests/OpenIddictValidationSystemNetHttpHandlersTests.cs @@ -85,13 +85,13 @@ public class OpenIddictValidationSystemNetHttpHandlersTests var context = new PrepareConfigurationRequestContext( CreateTransaction(Mock.Of>(), response)); var handler = new DecompressResponseContent( - CreateOptions(DecompressionMethods.All)); + CreateOptions(~DecompressionMethods.None)); // Act await handler.HandleAsync(context); // Assert - Assert.True(DecompressionMethods.All.HasFlag(method)); + Assert.True((~DecompressionMethods.None).HasFlag(method)); Assert.False(context.IsRejected); Assert.Empty(response.Content.Headers.ContentEncoding); Assert.Equal(Payload, await response.Content.ReadAsStringAsync());