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

[pull] dev from openiddict:dev #9

Merged
merged 3 commits into from
Jul 22, 2024
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
1 change: 1 addition & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@

<PropertyGroup
Condition=" ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))) ">
<DefineConstants>$(DefineConstants);SUPPORTS_APPLICATION_CONFIGURATION_INITIALIZATION</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_DIRECT_JSON_ELEMENT_SERIALIZATION</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_JSON_NODES</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ONE_SHOT_RANDOM_NUMBER_GENERATOR_METHODS</DefineConstants>
Expand Down
6 changes: 6 additions & 0 deletions sandbox/OpenIddict.Sandbox.WinForms.Client/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<TargetFrameworks>net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">$(TargetFrameworks);net8.0-windows7.0</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions sandbox/OpenIddict.Sandbox.WinForms.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
using OpenIddict.Sandbox.WinForms.Client;
using static OpenIddict.Abstractions.OpenIddictConstants;

#if SUPPORTS_APPLICATION_CONFIGURATION_INITIALIZATION
ApplicationConfiguration.Initialize();
#endif

var host = new HostBuilder()
// Note: applications for which a single instance is preferred can reference
// the Dapplo.Microsoft.Extensions.Hosting.AppServices package and call this
Expand Down
22 changes: 22 additions & 0 deletions sandbox/OpenIddict.Sandbox.WinForms.Client/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ await Task.Run(cancellationToken: stoppingToken, function: async () =>
}

// Ignore exceptions indicating that the host is shutting down and return immediately.
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
catch (OperationCanceledException exception) when (stoppingToken.IsCancellationRequested)
{
_source.SetResult(result: null);
_source.TrySetException(exception);
return;
}

catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
{
_source.SetResult(result: null);
_source.TrySetException(exception);
throw;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public static OpenIddictClientSystemNetHttpBuilder UseSystemNetHttp(this OpenIdd
builder.Services.TryAdd(OpenIddictClientSystemNetHttpHandlers.DefaultHandlers.Select(descriptor => descriptor.ServiceDescriptor));

// Register the built-in filters used by the default OpenIddict System.Net.Http event handlers.
#pragma warning disable CS0618
builder.Services.TryAddSingleton<RequireHttpMetadataUri>();
#pragma warning restore CS0618
builder.Services.TryAddSingleton<RequireHttpUri>();

// Note: TryAddEnumerable() is used here to ensure the initializers are registered only once.
builder.Services.TryAddEnumerable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ namespace OpenIddict.Client.SystemNetHttp;
public static class OpenIddictClientSystemNetHttpHandlerFilters
{
/// <summary>
/// Represents a filter that excludes the associated handlers if the metadata URI of the issuer is not available.
/// Represents a filter that excludes the associated handlers if the URI is not an HTTP or HTTPS address.
/// </summary>
[Obsolete("This filter is obsolete and will be removed in a future version.")]
public sealed class RequireHttpMetadataUri : IOpenIddictClientHandlerFilter<BaseExternalContext>
{
/// <inheritdoc/>
Expand All @@ -25,7 +26,26 @@ public ValueTask<bool> IsActiveAsync(BaseExternalContext context)
}

return new(
string.Equals(context.RemoteUri?.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) ||
string.Equals(context.RemoteUri?.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) ||
string.Equals(context.RemoteUri?.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase));
}
}

/// <summary>
/// Represents a filter that excludes the associated handlers if the URI is not an HTTP or HTTPS address.
/// </summary>
public sealed class RequireHttpUri : IOpenIddictClientHandlerFilter<BaseExternalContext>
{
/// <inheritdoc/>
public ValueTask<bool> IsActiveAsync(BaseExternalContext context)
{
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

return new(
string.Equals(context.RemoteUri?.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) ||
string.Equals(context.RemoteUri?.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public sealed class AttachBasicAuthenticationCredentials : IOpenIddictClientHand
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<PrepareDeviceAuthorizationRequestContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachBasicAuthenticationCredentials>()
.SetOrder(AttachHttpParameters<PrepareDeviceAuthorizationRequestContext>.Descriptor.Order - 500)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public sealed class AttachBasicAuthenticationCredentials : IOpenIddictClientHand
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<PrepareTokenRequestContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachBasicAuthenticationCredentials>()
.SetOrder(AttachHttpParameters<PrepareTokenRequestContext>.Descriptor.Order - 500)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public sealed class AttachBasicAuthenticationCredentials : IOpenIddictClientHand
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<PrepareIntrospectionRequestContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachBasicAuthenticationCredentials>()
.SetOrder(AttachHttpParameters<PrepareIntrospectionRequestContext>.Descriptor.Order - 500)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public sealed class AttachBasicAuthenticationCredentials : IOpenIddictClientHand
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<PrepareRevocationRequestContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachBasicAuthenticationCredentials>()
.SetOrder(AttachHttpParameters<PrepareRevocationRequestContext>.Descriptor.Order - 500)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public sealed class AttachBearerAccessToken : IOpenIddictClientHandler<PrepareUs
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<PrepareUserinfoRequestContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachBearerAccessToken>()
.SetOrder(AttachHttpParameters<PrepareUserinfoRequestContext>.Descriptor.Order - 500)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -93,7 +93,7 @@ public sealed class ExtractUserinfoTokenHttpResponse : IOpenIddictClientHandler<
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<ExtractUserinfoResponseContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<ExtractUserinfoTokenHttpResponse>()
.SetOrder(ExtractJsonHttpResponse<ExtractUserinfoResponseContext>.Descriptor.Order - 500)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CreateHttpClient(IHttpClientFactory factory)
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<CreateHttpClient<TContext>>()
.SetOrder(int.MinValue + 100_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -81,7 +81,7 @@ public sealed class PrepareGetHttpRequest<TContext> : IOpenIddictClientHandler<T
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<PrepareGetHttpRequest<TContext>>()
.SetOrder(CreateHttpClient<TContext>.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -113,7 +113,7 @@ public sealed class PreparePostHttpRequest<TContext> : IOpenIddictClientHandler<
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<PreparePostHttpRequest<TContext>>()
.SetOrder(PrepareGetHttpRequest<TContext>.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -145,7 +145,7 @@ public sealed class AttachHttpVersion<TContext> : IOpenIddictClientHandler<TCont
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachHttpVersion<TContext>>()
.SetOrder(PreparePostHttpRequest<TContext>.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -193,7 +193,7 @@ public sealed class AttachJsonAcceptHeaders<TContext> : IOpenIddictClientHandler
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachJsonAcceptHeaders<TContext>>()
.SetOrder(AttachHttpVersion<TContext>.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -238,7 +238,7 @@ public AttachUserAgentHeader(IOptionsMonitor<OpenIddictClientSystemNetHttpOption
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachUserAgentHeader<TContext>>()
.SetOrder(AttachJsonAcceptHeaders<TContext>.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -292,7 +292,7 @@ public AttachFromHeader(IOptionsMonitor<OpenIddictClientSystemNetHttpOptions> op
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachFromHeader<TContext>>()
.SetOrder(AttachUserAgentHeader<TContext>.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -328,7 +328,7 @@ public sealed class AttachHttpParameters<TContext> : IOpenIddictClientHandler<TC
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<AttachHttpParameters<TContext>>()
.SetOrder(int.MaxValue - 100_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -388,7 +388,7 @@ public sealed class SendHttpRequest<TContext> : IOpenIddictClientHandler<TContex
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<SendHttpRequest<TContext>>()
.SetOrder(DecompressResponseContent<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -452,7 +452,7 @@ public sealed class DisposeHttpRequest<TContext> : IOpenIddictClientHandler<TCon
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<DisposeHttpRequest<TContext>>()
.SetOrder(int.MaxValue - 100_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -490,7 +490,7 @@ public sealed class DecompressResponseContent<TContext> : IOpenIddictClientHandl
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<DecompressResponseContent<TContext>>()
.SetOrder(ExtractJsonHttpResponse<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -636,7 +636,7 @@ public sealed class ExtractJsonHttpResponse<TContext> : IOpenIddictClientHandler
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<ExtractJsonHttpResponse<TContext>>()
.SetOrder(ExtractWwwAuthenticateHeader<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -715,7 +715,7 @@ public sealed class ExtractWwwAuthenticateHeader<TContext> : IOpenIddictClientHa
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<ExtractWwwAuthenticateHeader<TContext>>()
.SetOrder(ExtractEmptyHttpResponse<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -798,7 +798,7 @@ public sealed class ExtractEmptyHttpResponse<TContext> : IOpenIddictClientHandle
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<ExtractEmptyHttpResponse<TContext>>()
.SetOrder(ValidateHttpResponse<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -844,7 +844,7 @@ public sealed class ValidateHttpResponse<TContext> : IOpenIddictClientHandler<TC
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<ValidateHttpResponse<TContext>>()
.SetOrder(DisposeHttpResponse<TContext>.Descriptor.Order - 50_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down Expand Up @@ -914,7 +914,7 @@ public sealed class DisposeHttpResponse<TContext> : IOpenIddictClientHandler<TCo
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.AddFilter<RequireHttpUri>()
.UseSingletonHandler<DisposeHttpResponse<TContext>>()
.SetOrder(int.MaxValue - 100_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
Expand Down
Loading
Loading