From 985a9ec191b055c889a484acb13f860920136545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 26 Aug 2019 15:25:36 +0200 Subject: [PATCH] Introduce OpenIddictMessage.Count to allow retrieving the number of parameters contained in a message --- src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs | 5 +++++ .../OpenIddictServerAspNetCoreHandlers.Authentication.cs | 2 +- .../OpenIddictServerAspNetCoreHandlers.Session.cs | 2 +- .../OpenIddictServerOwinHandlers.Authentication.cs | 2 +- .../OpenIddictServerOwinHandlers.Session.cs | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs index 07ebc16d..cd5ff4be 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs @@ -174,6 +174,11 @@ namespace OpenIddict.Abstractions set => SetParameter(name, value); } + /// + /// Gets the number of parameters contained in the current message. + /// + public int Count => Parameters.Count; + /// /// Gets the dictionary containing the parameters. /// diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs index a1f2fc90..7182e08f 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs @@ -200,7 +200,7 @@ namespace OpenIddict.Server.AspNetCore // Don't cache the request if the request doesn't include any parameter. // If a request_id parameter can be found in the authorization request, // ignore the following logic to prevent an infinite redirect loop. - if (context.Request.GetParameters().IsEmpty || !string.IsNullOrEmpty(context.Request.RequestId)) + if (context.Request.Count == 0 || !string.IsNullOrEmpty(context.Request.RequestId)) { return; } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs index 18913a36..e981defd 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs @@ -198,7 +198,7 @@ namespace OpenIddict.Server.AspNetCore // Don't cache the request if the request doesn't include any parameter. // If a request_id parameter can be found in the logout request, // ignore the following logic to prevent an infinite redirect loop. - if (context.Request.GetParameters().IsEmpty || !string.IsNullOrEmpty(context.Request.RequestId)) + if (context.Request.Count == 0 || !string.IsNullOrEmpty(context.Request.RequestId)) { return; } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs index 8197f584..6e19c14e 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs @@ -197,7 +197,7 @@ namespace OpenIddict.Server.Owin // Don't cache the request if the request doesn't include any parameter. // If a request_id parameter can be found in the authorization request, // ignore the following logic to prevent an infinite redirect loop. - if (context.Request.GetParameters().IsEmpty || !string.IsNullOrEmpty(context.Request.RequestId)) + if (context.Request.Count == 0 || !string.IsNullOrEmpty(context.Request.RequestId)) { return; } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs index 7a6e865e..accc858b 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs @@ -195,7 +195,7 @@ namespace OpenIddict.Server.Owin // Don't cache the request if the request doesn't include any parameter. // If a request_id parameter can be found in the logout request, // ignore the following logic to prevent an infinite redirect loop. - if (context.Request.GetParameters().IsEmpty || !string.IsNullOrEmpty(context.Request.RequestId)) + if (context.Request.Count == 0 || !string.IsNullOrEmpty(context.Request.RequestId)) { return; }