Browse Source

Update the AttachDynamicPortToRedirectUri/AttachDynamicPortToPostLogoutRedirectUri handlers to no-op when the challenge/sign-out demands are handled via WebAuthenticationBroker

pull/2017/head
Kévin Chalet 2 years ago
parent
commit
e50cb8c62d
  1. 8
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs
  2. 7
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs

8
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs

@ -1599,6 +1599,10 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessChallengeContext>() = OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessChallengeContext>()
.AddFilter<RequireInteractiveSession>() .AddFilter<RequireInteractiveSession>()
.AddFilter<RequireInteractiveGrantType>() .AddFilter<RequireInteractiveGrantType>()
// Note: only apply the dynamic port replacement logic if the callback request
// is going to be received by the system browser to ensure it doesn't apply to
// challenge demands handled via a web authentication broker are not affected.
.AddFilter<RequireSystemBrowser>()
.UseSingletonHandler<AttachDynamicPortToRedirectUri>() .UseSingletonHandler<AttachDynamicPortToRedirectUri>()
.SetOrder(AttachRedirectUri.Descriptor.Order + 500) .SetOrder(AttachRedirectUri.Descriptor.Order + 500)
.SetType(OpenIddictClientHandlerType.BuiltIn) .SetType(OpenIddictClientHandlerType.BuiltIn)
@ -1775,6 +1779,10 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
public static OpenIddictClientHandlerDescriptor Descriptor { get; } public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessSignOutContext>() = OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessSignOutContext>()
.AddFilter<RequireInteractiveSession>() .AddFilter<RequireInteractiveSession>()
// Note: only apply the dynamic port replacement logic if the callback request
// is going to be received by the system browser to ensure it doesn't apply to
// sign-out demands handled via a web authentication broker are not affected.
.AddFilter<RequireSystemBrowser>()
.UseSingletonHandler<AttachDynamicPortToPostLogoutRedirectUri>() .UseSingletonHandler<AttachDynamicPortToPostLogoutRedirectUri>()
.SetOrder(AttachPostLogoutRedirectUri.Descriptor.Order + 500) .SetOrder(AttachPostLogoutRedirectUri.Descriptor.Order + 500)
.SetType(OpenIddictClientHandlerType.BuiltIn) .SetType(OpenIddictClientHandlerType.BuiltIn)

7
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs

@ -94,9 +94,16 @@ public sealed class OpenIddictClientSystemIntegrationHttpListener : BackgroundSe
// Ignore exceptions indicating that the host is shutting down and return immediately. // Ignore exceptions indicating that the host is shutting down and return immediately.
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested) catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{ {
_source.SetResult(result: null);
return; return;
} }
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
{
_source.SetResult(result: null);
throw;
}
static (HttpListener Listener, int Port) CreateHttpListener(List<int> ports, CancellationToken cancellationToken) static (HttpListener Listener, int Port) CreateHttpListener(List<int> ports, CancellationToken cancellationToken)
{ {
// Note: HttpListener doesn't offer a native way to select a non-busy port from // Note: HttpListener doesn't offer a native way to select a non-busy port from

Loading…
Cancel
Save