diff --git a/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs b/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs
index 0fa1c993..cf336475 100644
--- a/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs
+++ b/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs
@@ -54,15 +54,18 @@ public static class MauiProgram
// providers that use the user agent as a way to throttle requests (e.g Reddit).
options.UseSystemNetHttp()
.SetProductInformation(typeof(MauiProgram).Assembly)
-#if IOS
- // Warning: server certificate validation is disabled to simplify testing the MAUI
- // application with the iOS simulator: in production, it SHOULD NEVER be disabled.
+ .ConfigureHttpClientHandler(static (context, handler) =>
+ {
+#if DEBUG && IOS
#pragma warning disable MA0039
- .ConfigureHttpClientHandler("Local", handler => handler.ServerCertificateCustomValidationCallback =
- HttpClientHandler.DangerousAcceptAnyServerCertificateValidator)
+ // Warning: server certificate validation is disabled to simplify testing the MAUI
+ // application with the iOS simulator: in production, it SHOULD NEVER be disabled.
+ handler.ServerCertificateCustomValidationCallback = context.Registration.ProviderName is "Local"
+ ? HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
+ : handler.ServerCertificateCustomValidationCallback;
#pragma warning restore MA0039
#endif
- ;
+ });
// Add a client registration matching the client application definition in the server project.
options.AddRegistration(new OpenIddictClientRegistration
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpBuilder.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpBuilder.cs
index 1d7ba028..6d19fb7b 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpBuilder.cs
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpBuilder.cs
@@ -11,7 +11,6 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mail;
using System.Reflection;
-using OpenIddict.Client;
using OpenIddict.Client.SystemNetHttp;
using Polly;
@@ -62,47 +61,6 @@ public sealed class OpenIddictClientSystemNetHttpBuilder
return this;
}
- ///
- /// Configures the used by the OpenIddict client/System.Net.Http integration.
- ///
- ///
- /// Note: customizations configured using this method apply to all client registrations.
- ///
- /// The delegate used to configure the .
- /// The instance.
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClient(Action configuration)
- {
- ArgumentNullException.ThrowIfNull(configuration);
-
- return ConfigureHttpClient((registration, client) => configuration(client));
- }
-
- ///
- /// Configures the used by the OpenIddict client/System.Net.Http integration.
- ///
- ///
- /// Note: customizations configured using this method only apply
- /// to client registrations that use the specified provider name.
- ///
- /// The provider name, to which the customizations are applied.
- /// The delegate used to configure the .
- /// The instance.
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClient(string provider, Action configuration)
- {
- ArgumentNullException.ThrowIfNull(configuration);
- ArgumentException.ThrowIfNullOrEmpty(provider);
-
- return ConfigureHttpClient((registration, client) =>
- {
- if (string.Equals(registration.ProviderName, provider, StringComparison.Ordinal))
- {
- configuration(client);
- }
- });
- }
-
///
/// Configures the used by the OpenIddict client/System.Net.Http integration.
///
@@ -113,54 +71,14 @@ public sealed class OpenIddictClientSystemNetHttpBuilder
/// The delegate used to configure the .
/// The instance.
[EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClient(Action configuration)
+ public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClient(
+ Action configuration)
{
ArgumentNullException.ThrowIfNull(configuration);
return Configure(options => options.HttpClientActions.Add(configuration));
}
- ///
- /// Configures the used by the OpenIddict client/System.Net.Http integration.
- ///
- ///
- /// Note: customizations configured using this method apply to all client registrations.
- ///
- /// The delegate used to configure the .
- /// The instance.
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClientHandler(Action configuration)
- {
- ArgumentNullException.ThrowIfNull(configuration);
-
- return ConfigureHttpClientHandler((registration, handler) => configuration(handler));
- }
-
- ///
- /// Configures the used by the OpenIddict client/System.Net.Http integration.
- ///
- ///
- /// Note: customizations configured using this method only apply
- /// to client registrations that use the specified provider name.
- ///
- /// The provider name, to which the customizations are applied.
- /// The delegate used to configure the .
- /// The instance.
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClientHandler(string provider, Action configuration)
- {
- ArgumentNullException.ThrowIfNull(configuration);
- ArgumentException.ThrowIfNullOrEmpty(provider);
-
- return ConfigureHttpClientHandler((registration, handler) =>
- {
- if (string.Equals(registration.ProviderName, provider, StringComparison.Ordinal))
- {
- configuration(handler);
- }
- });
- }
-
///
/// Configures the used by the OpenIddict client/System.Net.Http integration.
///
@@ -172,7 +90,7 @@ public sealed class OpenIddictClientSystemNetHttpBuilder
/// The instance.
[EditorBrowsable(EditorBrowsableState.Advanced)]
public OpenIddictClientSystemNetHttpBuilder ConfigureHttpClientHandler(
- Action configuration)
+ Action configuration)
{
ArgumentNullException.ThrowIfNull(configuration);
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpConfiguration.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpConfiguration.cs
index 8d24ee40..f1b28978 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpConfiguration.cs
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpConfiguration.cs
@@ -93,7 +93,7 @@ public sealed class OpenIddictClientSystemNetHttpConfiguration : IConfigureOptio
// Register the user-defined HTTP client actions.
foreach (var action in settings.HttpClientActions)
{
- options.HttpClientActions.Add(client => action(context.Registration, client));
+ options.HttpClientActions.Add(client => action(context, client));
}
options.HttpMessageHandlerBuilderActions.Add(builder =>
@@ -140,7 +140,7 @@ public sealed class OpenIddictClientSystemNetHttpConfiguration : IConfigureOptio
// Register the user-defined HTTP client handler actions.
foreach (var action in settings.HttpClientHandlerActions)
{
- options.HttpMessageHandlerBuilderActions.Add(builder => action(context.Registration,
+ options.HttpMessageHandlerBuilderActions.Add(builder => action(context,
builder.PrimaryHandler as HttpClientHandler
?? throw new InvalidOperationException(SR.FormatID0373(typeof(HttpClientHandler).FullName))));
}
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs
index 8823c8eb..dcd5bcd1 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs
@@ -15,7 +15,6 @@ namespace OpenIddict.Client.SystemNetHttp;
///
/// Represents the context used by the System.Net.Http integration when creating a new HTTP client.
///
-[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class OpenIddictClientSystemNetHttpContext
{
private static readonly AsyncLocal _current = new();
@@ -29,6 +28,7 @@ public sealed class OpenIddictClientSystemNetHttpContext
///
/// Gets or sets the ambient context for the current execution flow.
///
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static OpenIddictClientSystemNetHttpContext? Current
{
get => _current.Value;
@@ -45,6 +45,7 @@ public sealed class OpenIddictClientSystemNetHttpContext
///
/// The client context for which to compute the stable identifier.
/// A string representing the stable identifier for the specified context.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static string ComputeStableId(OpenIddictClientSystemNetHttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs
index c9162bfd..6578e50c 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs
@@ -95,11 +95,11 @@ public sealed class OpenIddictClientSystemNetHttpOptions
/// Gets the user-defined actions used to amend the
/// instances created by the OpenIddict client/System.Net.Http integration.
///
- public List> HttpClientActions { get; } = [];
+ public List> HttpClientActions { get; } = [];
///
/// Gets the user-defined actions used to amend the
/// instances created by the OpenIddict client/System.Net.Http integration.
///
- public List> HttpClientHandlerActions { get; } = [];
+ public List> HttpClientHandlerActions { get; } = [];
}
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs
index c64830ac..d643d877 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs
@@ -67,7 +67,8 @@ public sealed class OpenIddictValidationSystemNetHttpBuilder
/// The delegate used to configure the .
/// The instance.
[EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictValidationSystemNetHttpBuilder ConfigureHttpClient(Action configuration)
+ public OpenIddictValidationSystemNetHttpBuilder ConfigureHttpClient(
+ Action configuration)
{
ArgumentNullException.ThrowIfNull(configuration);
@@ -80,7 +81,8 @@ public sealed class OpenIddictValidationSystemNetHttpBuilder
/// The delegate used to configure the .
/// The instance.
[EditorBrowsable(EditorBrowsableState.Advanced)]
- public OpenIddictValidationSystemNetHttpBuilder ConfigureHttpClientHandler(Action configuration)
+ public OpenIddictValidationSystemNetHttpBuilder ConfigureHttpClientHandler(
+ Action configuration)
{
ArgumentNullException.ThrowIfNull(configuration);
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs
index f3421312..06d2f771 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs
@@ -90,7 +90,7 @@ public sealed class OpenIddictValidationSystemNetHttpConfiguration : IConfigureO
// Register the user-defined HTTP client actions.
foreach (var action in settings.HttpClientActions)
{
- options.HttpClientActions.Add(action);
+ options.HttpClientActions.Add(client => action(context, client));
}
options.HttpMessageHandlerBuilderActions.Add(builder =>
@@ -137,7 +137,7 @@ public sealed class OpenIddictValidationSystemNetHttpConfiguration : IConfigureO
// Register the user-defined HTTP client handler actions.
foreach (var action in settings.HttpClientHandlerActions)
{
- options.HttpMessageHandlerBuilderActions.Add(builder => action(builder.PrimaryHandler as HttpClientHandler
+ options.HttpMessageHandlerBuilderActions.Add(builder => action(context, builder.PrimaryHandler as HttpClientHandler
?? throw new InvalidOperationException(SR.FormatID0373(typeof(HttpClientHandler).FullName))));
}
}
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs
index 6f1f3954..72245216 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs
@@ -14,7 +14,6 @@ namespace OpenIddict.Validation.SystemNetHttp;
///
/// Represents the context used by the System.Net.Http integration when creating a new HTTP client.
///
-[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class OpenIddictValidationSystemNetHttpContext
{
private static readonly AsyncLocal _current = new();
@@ -28,6 +27,7 @@ public sealed class OpenIddictValidationSystemNetHttpContext
///
/// Gets or sets the ambient context for the current execution flow.
///
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static OpenIddictValidationSystemNetHttpContext? Current
{
get => _current.Value;
@@ -39,6 +39,7 @@ public sealed class OpenIddictValidationSystemNetHttpContext
///
/// The client context for which to compute the stable identifier.
/// A string representing the stable identifier for the specified context.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static string ComputeStableId(OpenIddictValidationSystemNetHttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs
index a9913568..0227ba49 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpOptions.cs
@@ -95,11 +95,11 @@ public sealed class OpenIddictValidationSystemNetHttpOptions
/// Gets the user-defined actions used to amend the
/// instances created by the OpenIddict validation/System.Net.Http integration.
///
- public List> HttpClientActions { get; } = [];
+ public List> HttpClientActions { get; } = [];
///
/// Gets the user-defined actions used to amend the
/// instances created by the OpenIddict validation/System.Net.Http integration.
///
- public List> HttpClientHandlerActions { get; } = [];
+ public List> HttpClientHandlerActions { get; } = [];
}