Browse Source

Replace Task by ValueTask in OpenIddict.Server/OpenIddict.Server.AspNetCore/OpenIddict.Server.Owin

pull/780/head
Kévin Chalet 7 years ago
committed by GitHub
parent
commit
9d2446764b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs
  2. 64
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs
  3. 6
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs
  4. 6
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs
  5. 12
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Serialization.cs
  6. 60
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs
  7. 60
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs
  8. 4
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs
  9. 52
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Serialization.cs
  10. 32
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs
  11. 54
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs
  12. 6
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs
  13. 6
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs
  14. 12
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Serialization.cs
  15. 50
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
  16. 60
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
  17. 2
      src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs
  18. 4
      src/OpenIddict.Server/IOpenIddictServerHandler.cs
  19. 2
      src/OpenIddict.Server/IOpenIddictServerHandlerFilter.cs
  20. 2
      src/OpenIddict.Server/IOpenIddictServerProvider.cs
  21. 8
      src/OpenIddict.Server/OpenIddictServerHandler.cs
  22. 2
      src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs
  23. 48
      src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs
  24. 170
      src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs
  25. 110
      src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs
  26. 168
      src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs
  27. 66
      src/OpenIddict.Server/OpenIddictServerHandlers.Serialization.cs
  28. 51
      src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
  29. 46
      src/OpenIddict.Server/OpenIddictServerHandlers.cs
  30. 4
      src/OpenIddict.Server/OpenIddictServerProvider.cs

36
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs

@ -31,14 +31,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireAuthorizationEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireAuthorizationEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableAuthorizationEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableAuthorizationEndpointPassthrough);
} }
} }
@ -52,14 +52,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireErrorPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireErrorPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableErrorPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableErrorPassthrough);
} }
} }
@ -68,14 +68,14 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
public class RequireHttpRequest : IOpenIddictServerHandlerFilter<BaseContext> public class RequireHttpRequest : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.Transaction.GetHttpRequest() != null); return new ValueTask<bool>(context.Transaction.GetHttpRequest() != null);
} }
} }
/// <summary> /// <summary>
@ -89,14 +89,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireLogoutEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireLogoutEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableLogoutEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableLogoutEndpointPassthrough);
} }
} }
@ -110,14 +110,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireTransportSecurityRequirementEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireTransportSecurityRequirementEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!_options.CurrentValue.DisableTransportSecurityRequirement); return new ValueTask<bool>(!_options.CurrentValue.DisableTransportSecurityRequirement);
} }
} }
@ -131,14 +131,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireRequestCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireRequestCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableRequestCaching); return new ValueTask<bool>(_options.CurrentValue.EnableRequestCaching);
} }
} }
@ -152,14 +152,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireStatusCodePagesIntegrationEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireStatusCodePagesIntegrationEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableStatusCodePagesIntegration); return new ValueTask<bool>(_options.CurrentValue.EnableStatusCodePagesIntegration);
} }
} }
@ -174,14 +174,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireTokenEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireTokenEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableTokenEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableTokenEndpointPassthrough);
} }
} }
@ -196,14 +196,14 @@ namespace OpenIddict.Server.AspNetCore
public RequireUserinfoEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options) public RequireUserinfoEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerAspNetCoreOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableUserinfoEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableUserinfoEndpointPassthrough);
} }
} }
} }

64
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs

@ -93,9 +93,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -180,9 +180,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -261,9 +261,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] HandleAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -272,7 +272,7 @@ namespace OpenIddict.Server.AspNetCore
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -310,9 +310,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -321,7 +321,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.Request?.RequestId)) if (string.IsNullOrEmpty(context.Request?.RequestId))
{ {
return Task.CompletedTask; return default;
} }
// Note: the ApplyAuthorizationResponse event is called for both successful // Note: the ApplyAuthorizationResponse event is called for both successful
@ -330,7 +330,7 @@ namespace OpenIddict.Server.AspNetCore
// Note: the cache key is always prefixed with a specific marker // Note: the cache key is always prefixed with a specific marker
// to avoid collisions with the other types of cached payloads. // to avoid collisions with the other types of cached payloads.
return _cache.RemoveAsync(Cache.AuthorizationRequest + context.Request.RequestId); return new ValueTask(_cache.RemoveAsync(Cache.AuthorizationRequest + context.Request.RequestId));
} }
} }
@ -360,9 +360,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public async ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -454,9 +454,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -474,7 +474,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.RedirectUri) || if (string.IsNullOrEmpty(context.RedirectUri) ||
!string.Equals(context.ResponseMode, ResponseModes.Query, StringComparison.Ordinal)) !string.Equals(context.ResponseMode, ResponseModes.Query, StringComparison.Ordinal))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The authorization response was successfully returned to " + context.Logger.LogInformation("The authorization response was successfully returned to " +
@ -494,7 +494,7 @@ namespace OpenIddict.Server.AspNetCore
response.Redirect(location); response.Redirect(location);
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -519,9 +519,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -539,7 +539,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.RedirectUri) || if (string.IsNullOrEmpty(context.RedirectUri) ||
!string.Equals(context.ResponseMode, ResponseModes.Fragment, StringComparison.Ordinal)) !string.Equals(context.ResponseMode, ResponseModes.Fragment, StringComparison.Ordinal))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The authorization response was successfully returned to " + context.Logger.LogInformation("The authorization response was successfully returned to " +
@ -562,7 +562,7 @@ namespace OpenIddict.Server.AspNetCore
response.Redirect(builder.ToString()); response.Redirect(builder.ToString());
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
static bool Contains(StringBuilder builder, char delimiter) static bool Contains(StringBuilder builder, char delimiter)
{ {
@ -603,9 +603,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -622,7 +622,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.RedirectUri)) if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.RedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// Apply a 400 status code by default. // Apply a 400 status code by default.
@ -630,7 +630,7 @@ namespace OpenIddict.Server.AspNetCore
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -656,9 +656,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -680,7 +680,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.Error) || !string.IsNullOrEmpty(context.RedirectUri)) if (string.IsNullOrEmpty(context.Error) || !string.IsNullOrEmpty(context.RedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// Determine if the status code pages middleware has been enabled for this request. // Determine if the status code pages middleware has been enabled for this request.
@ -689,7 +689,7 @@ namespace OpenIddict.Server.AspNetCore
var feature = response.HttpContext.Features.Get<IStatusCodePagesFeature>(); var feature = response.HttpContext.Features.Get<IStatusCodePagesFeature>();
if (feature == null || !feature.Enabled) if (feature == null || !feature.Enabled)
{ {
return Task.CompletedTask; return default;
} }
// Replace the default status code to return a 400 response. // Replace the default status code to return a 400 response.
@ -700,7 +700,7 @@ namespace OpenIddict.Server.AspNetCore
// to rewrite the response using the logic defined by the developer when registering it. // to rewrite the response using the logic defined by the developer when registering it.
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -725,9 +725,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public async ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {

6
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs

@ -66,9 +66,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -100,7 +100,7 @@ namespace OpenIddict.Server.AspNetCore
context.Issuer = issuer; context.Issuer = issuer;
} }
return Task.CompletedTask; return default;
} }
} }
} }

6
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs

@ -56,9 +56,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleTokenRequestContext context) public ValueTask HandleAsync([NotNull] HandleTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -75,7 +75,7 @@ namespace OpenIddict.Server.AspNetCore
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
} }

12
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Serialization.cs

@ -59,9 +59,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -93,7 +93,7 @@ namespace OpenIddict.Server.AspNetCore
context.Issuer = issuer; context.Issuer = issuer;
} }
return Task.CompletedTask; return default;
} }
} }
@ -119,9 +119,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -153,7 +153,7 @@ namespace OpenIddict.Server.AspNetCore
context.TokenValidationParameters.ValidIssuer = issuer.AbsoluteUri; context.TokenValidationParameters.ValidIssuer = issuer.AbsoluteUri;
} }
return Task.CompletedTask; return default;
} }
} }
} }

60
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs

@ -91,9 +91,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractLogoutRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -178,9 +178,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractLogoutRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -259,9 +259,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleLogoutRequestContext context) public ValueTask HandleAsync([NotNull] HandleLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -270,7 +270,7 @@ namespace OpenIddict.Server.AspNetCore
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -308,9 +308,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -319,7 +319,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.Request?.RequestId)) if (string.IsNullOrEmpty(context.Request?.RequestId))
{ {
return Task.CompletedTask; return default;
} }
// Note: the ApplyLogoutResponse event is called for both successful // Note: the ApplyLogoutResponse event is called for both successful
@ -328,7 +328,7 @@ namespace OpenIddict.Server.AspNetCore
// Note: the cache key is always prefixed with a specific marker // Note: the cache key is always prefixed with a specific marker
// to avoid collisions with the other types of cached payloads. // to avoid collisions with the other types of cached payloads.
return _cache.RemoveAsync(Cache.LogoutRequest + context.Request.RequestId); return new ValueTask(_cache.RemoveAsync(Cache.LogoutRequest + context.Request.RequestId));
} }
} }
@ -353,9 +353,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -372,13 +372,13 @@ namespace OpenIddict.Server.AspNetCore
if (!string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (!string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The logout response was successfully returned: {Response}.", response); context.Logger.LogInformation("The logout response was successfully returned: {Response}.", response);
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -403,9 +403,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -422,7 +422,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The logout response was successfully returned to '{PostLogoutRedirectUri}': {Response}.", context.Logger.LogInformation("The logout response was successfully returned to '{PostLogoutRedirectUri}': {Response}.",
@ -441,7 +441,7 @@ namespace OpenIddict.Server.AspNetCore
response.Redirect(location); response.Redirect(location);
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -469,9 +469,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -488,7 +488,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// Apply a 400 status code by default. // Apply a 400 status code by default.
@ -496,7 +496,7 @@ namespace OpenIddict.Server.AspNetCore
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -522,9 +522,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -546,7 +546,7 @@ namespace OpenIddict.Server.AspNetCore
if (string.IsNullOrEmpty(context.Error) || !string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (string.IsNullOrEmpty(context.Error) || !string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// Determine if the status code pages middleware has been enabled for this request. // Determine if the status code pages middleware has been enabled for this request.
@ -555,7 +555,7 @@ namespace OpenIddict.Server.AspNetCore
var feature = response.HttpContext.Features.Get<IStatusCodePagesFeature>(); var feature = response.HttpContext.Features.Get<IStatusCodePagesFeature>();
if (feature == null || !feature.Enabled) if (feature == null || !feature.Enabled)
{ {
return Task.CompletedTask; return default;
} }
// Replace the default status code to return a 400 response. // Replace the default status code to return a 400 response.
@ -566,7 +566,7 @@ namespace OpenIddict.Server.AspNetCore
// to rewrite the response using the logic defined by the developer when registering it. // to rewrite the response using the logic defined by the developer when registering it.
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -591,9 +591,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public async ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {

60
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs

@ -61,9 +61,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessRequestContext context) public ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -89,7 +89,7 @@ namespace OpenIddict.Server.AspNetCore
Matches(context.Options.UserinfoEndpointUris) ? OpenIddictServerEndpointType.Userinfo : Matches(context.Options.UserinfoEndpointUris) ? OpenIddictServerEndpointType.Userinfo :
OpenIddictServerEndpointType.Unknown; OpenIddictServerEndpointType.Unknown;
return Task.CompletedTask; return default;
bool Matches(IList<Uri> addresses) bool Matches(IList<Uri> addresses)
{ {
@ -154,9 +154,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessRequestContext context) public ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -174,7 +174,7 @@ namespace OpenIddict.Server.AspNetCore
// Don't require that the host be present if the request is not handled by OpenIddict. // Don't require that the host be present if the request is not handled by OpenIddict.
if (context.EndpointType == OpenIddictServerEndpointType.Unknown) if (context.EndpointType == OpenIddictServerEndpointType.Unknown)
{ {
return Task.CompletedTask; return default;
} }
// Reject authorization requests sent without transport security. // Reject authorization requests sent without transport security.
@ -184,10 +184,10 @@ namespace OpenIddict.Server.AspNetCore
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "This server only accepts HTTPS requests."); description: "This server only accepts HTTPS requests.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -212,9 +212,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessRequestContext context) public ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -233,7 +233,7 @@ namespace OpenIddict.Server.AspNetCore
// by an OpenIddict endpoint or if an explicit issuer URL was set in the options. // by an OpenIddict endpoint or if an explicit issuer URL was set in the options.
if (context.Options.Issuer != null || context.EndpointType == OpenIddictServerEndpointType.Unknown) if (context.Options.Issuer != null || context.EndpointType == OpenIddictServerEndpointType.Unknown)
{ {
return Task.CompletedTask; return default;
} }
if (!request.Host.HasValue) if (!request.Host.HasValue)
@ -242,10 +242,10 @@ namespace OpenIddict.Server.AspNetCore
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'Host' header is missing."); description: "The mandatory 'Host' header is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -270,9 +270,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -301,10 +301,10 @@ namespace OpenIddict.Server.AspNetCore
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified HTTP method is not valid."); description: "The specified HTTP method is not valid.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -329,9 +329,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -416,9 +416,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -499,9 +499,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -519,7 +519,7 @@ namespace OpenIddict.Server.AspNetCore
string header = request.Headers[HeaderNames.Authorization]; string header = request.Headers[HeaderNames.Authorization];
if (string.IsNullOrEmpty(header) || !header.StartsWith("Basic ", StringComparison.OrdinalIgnoreCase)) if (string.IsNullOrEmpty(header) || !header.StartsWith("Basic ", StringComparison.OrdinalIgnoreCase))
{ {
return Task.CompletedTask; return default;
} }
// At this point, reject requests that use multiple client authentication methods. // At this point, reject requests that use multiple client authentication methods.
@ -532,7 +532,7 @@ namespace OpenIddict.Server.AspNetCore
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "Multiple client credentials cannot be specified."); description: "Multiple client credentials cannot be specified.");
return Task.CompletedTask; return default;
} }
try try
@ -547,14 +547,14 @@ namespace OpenIddict.Server.AspNetCore
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified client credentials are invalid."); description: "The specified client credentials are invalid.");
return Task.CompletedTask; return default;
} }
// Attach the basic authentication credentials to the request message. // Attach the basic authentication credentials to the request message.
context.Request.ClientId = UnescapeDataString(data.Substring(0, index)); context.Request.ClientId = UnescapeDataString(data.Substring(0, index));
context.Request.ClientSecret = UnescapeDataString(data.Substring(index + 1)); context.Request.ClientSecret = UnescapeDataString(data.Substring(index + 1));
return Task.CompletedTask; return default;
} }
catch catch
@ -563,7 +563,7 @@ namespace OpenIddict.Server.AspNetCore
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified client credentials are invalid."); description: "The specified client credentials are invalid.");
return Task.CompletedTask; return default;
} }
static string UnescapeDataString(string data) static string UnescapeDataString(string data)
@ -599,9 +599,9 @@ namespace OpenIddict.Server.AspNetCore
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {

4
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs

@ -29,14 +29,14 @@ namespace OpenIddict.Server.DataProtection
public RequirePreferDataProtectionFormatEnabled([NotNull] IOptionsMonitor<OpenIddictServerDataProtectionOptions> options) public RequirePreferDataProtectionFormatEnabled([NotNull] IOptionsMonitor<OpenIddictServerDataProtectionOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.PreferDataProtectionFormat); return new ValueTask<bool>(_options.CurrentValue.PreferDataProtectionFormat);
} }
} }
} }

52
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Serialization.cs

@ -89,9 +89,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -145,7 +145,7 @@ namespace OpenIddict.Server.DataProtection
context.Token = Base64UrlEncoder.Encode(protector.Protect(buffer.ToArray())); context.Token = Base64UrlEncoder.Encode(protector.Protect(buffer.ToArray()));
context.HandleSerialization(); context.HandleSerialization();
return Task.CompletedTask; return default;
// Note: the following local methods closely matches the logic used by ASP.NET Core's // Note: the following local methods closely matches the logic used by ASP.NET Core's
// authentication stack and MUST NOT be modified to ensure tokens encrypted using // authentication stack and MUST NOT be modified to ensure tokens encrypted using
@ -297,9 +297,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -323,7 +323,7 @@ namespace OpenIddict.Server.DataProtection
var (principal, properties) = Read(reader, version: 5); var (principal, properties) = Read(reader, version: 5);
if (principal == null) if (principal == null)
{ {
return Task.CompletedTask; return default;
} }
context.Principal = principal; context.Principal = principal;
@ -349,14 +349,14 @@ namespace OpenIddict.Server.DataProtection
context.HandleDeserialization(); context.HandleDeserialization();
return Task.CompletedTask; return default;
} }
catch (Exception exception) catch (Exception exception)
{ {
context.Logger.LogTrace(exception, "An exception occured while deserializing a token."); context.Logger.LogTrace(exception, "An exception occured while deserializing a token.");
return Task.CompletedTask; return default;
} }
static (ClaimsPrincipal principal, ImmutableDictionary<string, string> properties) Read(BinaryReader reader, int version) static (ClaimsPrincipal principal, ImmutableDictionary<string, string> properties) Read(BinaryReader reader, int version)
@ -508,9 +508,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeAccessTokenContext context) public ValueTask HandleAsync([NotNull] SerializeAccessTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -534,7 +534,7 @@ namespace OpenIddict.Server.DataProtection
var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes); var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes);
context.Properties[typeof(IDataProtector).FullName] = protector; context.Properties[typeof(IDataProtector).FullName] = protector;
return Task.CompletedTask; return default;
} }
} }
@ -562,9 +562,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeAuthorizationCodeContext context) public ValueTask HandleAsync([NotNull] SerializeAuthorizationCodeContext context)
{ {
if (context == null) if (context == null)
{ {
@ -588,7 +588,7 @@ namespace OpenIddict.Server.DataProtection
var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes); var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes);
context.Properties[typeof(IDataProtector).FullName] = protector; context.Properties[typeof(IDataProtector).FullName] = protector;
return Task.CompletedTask; return default;
} }
} }
@ -616,9 +616,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeRefreshTokenContext context) public ValueTask HandleAsync([NotNull] SerializeRefreshTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -642,7 +642,7 @@ namespace OpenIddict.Server.DataProtection
var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes); var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes);
context.Properties[typeof(IDataProtector).FullName] = protector; context.Properties[typeof(IDataProtector).FullName] = protector;
return Task.CompletedTask; return default;
} }
} }
@ -670,9 +670,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeAccessTokenContext context) public ValueTask HandleAsync([NotNull] DeserializeAccessTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -696,7 +696,7 @@ namespace OpenIddict.Server.DataProtection
var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes); var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes);
context.Properties[typeof(IDataProtector).FullName] = protector; context.Properties[typeof(IDataProtector).FullName] = protector;
return Task.CompletedTask; return default;
} }
} }
@ -724,9 +724,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeAuthorizationCodeContext context) public ValueTask HandleAsync([NotNull] DeserializeAuthorizationCodeContext context)
{ {
if (context == null) if (context == null)
{ {
@ -750,7 +750,7 @@ namespace OpenIddict.Server.DataProtection
var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes); var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes);
context.Properties[typeof(IDataProtector).FullName] = protector; context.Properties[typeof(IDataProtector).FullName] = protector;
return Task.CompletedTask; return default;
} }
} }
@ -778,9 +778,9 @@ namespace OpenIddict.Server.DataProtection
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeRefreshTokenContext context) public ValueTask HandleAsync([NotNull] DeserializeRefreshTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -804,7 +804,7 @@ namespace OpenIddict.Server.DataProtection
var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes); var protector = _options.CurrentValue.DataProtectionProvider.CreateProtector(purposes);
context.Properties[typeof(IDataProtector).FullName] = protector; context.Properties[typeof(IDataProtector).FullName] = protector;
return Task.CompletedTask; return default;
} }
} }
} }

32
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs

@ -29,14 +29,14 @@ namespace OpenIddict.Server.Owin
public RequireAuthorizationEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireAuthorizationEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableAuthorizationEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableAuthorizationEndpointPassthrough);
} }
} }
@ -50,14 +50,14 @@ namespace OpenIddict.Server.Owin
public RequireErrorPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireErrorPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableErrorPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableErrorPassthrough);
} }
} }
@ -72,14 +72,14 @@ namespace OpenIddict.Server.Owin
public RequireLogoutEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireLogoutEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableLogoutEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableLogoutEndpointPassthrough);
} }
} }
@ -88,14 +88,14 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
public class RequireOwinRequest : IOpenIddictServerHandlerFilter<BaseContext> public class RequireOwinRequest : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.Transaction.GetOwinRequest() != null); return new ValueTask<bool>(context.Transaction.GetOwinRequest() != null);
} }
} }
@ -109,14 +109,14 @@ namespace OpenIddict.Server.Owin
public RequireTransportSecurityRequirementEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireTransportSecurityRequirementEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!_options.CurrentValue.DisableTransportSecurityRequirement); return new ValueTask<bool>(!_options.CurrentValue.DisableTransportSecurityRequirement);
} }
} }
@ -130,14 +130,14 @@ namespace OpenIddict.Server.Owin
public RequireRequestCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireRequestCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableRequestCaching); return new ValueTask<bool>(_options.CurrentValue.EnableRequestCaching);
} }
} }
@ -152,14 +152,14 @@ namespace OpenIddict.Server.Owin
public RequireTokenEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireTokenEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableTokenEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableTokenEndpointPassthrough);
} }
} }
@ -174,14 +174,14 @@ namespace OpenIddict.Server.Owin
public RequireUserinfoEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) public RequireUserinfoEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options)
=> _options = options; => _options = options;
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(_options.CurrentValue.EnableUserinfoEndpointPassthrough); return new ValueTask<bool>(_options.CurrentValue.EnableUserinfoEndpointPassthrough);
} }
} }
} }

54
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs

@ -90,9 +90,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -177,9 +177,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -258,9 +258,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] HandleAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -269,7 +269,7 @@ namespace OpenIddict.Server.Owin
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -307,9 +307,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -318,7 +318,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.Request?.RequestId)) if (string.IsNullOrEmpty(context.Request?.RequestId))
{ {
return Task.CompletedTask; return default;
} }
// Note: the ApplyAuthorizationResponse event is called for both successful // Note: the ApplyAuthorizationResponse event is called for both successful
@ -327,7 +327,7 @@ namespace OpenIddict.Server.Owin
// Note: the cache key is always prefixed with a specific marker // Note: the cache key is always prefixed with a specific marker
// to avoid collisions with the other types of cached payloads. // to avoid collisions with the other types of cached payloads.
return _cache.RemoveAsync(Cache.AuthorizationRequest + context.Request.RequestId); return new ValueTask(_cache.RemoveAsync(Cache.AuthorizationRequest + context.Request.RequestId));
} }
} }
@ -357,9 +357,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public async ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -452,9 +452,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -472,7 +472,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.RedirectUri) || if (string.IsNullOrEmpty(context.RedirectUri) ||
!string.Equals(context.ResponseMode, ResponseModes.Query, StringComparison.Ordinal)) !string.Equals(context.ResponseMode, ResponseModes.Query, StringComparison.Ordinal))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The authorization response was successfully returned to " + context.Logger.LogInformation("The authorization response was successfully returned to " +
@ -492,7 +492,7 @@ namespace OpenIddict.Server.Owin
response.Redirect(location); response.Redirect(location);
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -517,9 +517,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -537,7 +537,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.RedirectUri) || if (string.IsNullOrEmpty(context.RedirectUri) ||
!string.Equals(context.ResponseMode, ResponseModes.Fragment, StringComparison.Ordinal)) !string.Equals(context.ResponseMode, ResponseModes.Fragment, StringComparison.Ordinal))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The authorization response was successfully returned to " + context.Logger.LogInformation("The authorization response was successfully returned to " +
@ -560,7 +560,7 @@ namespace OpenIddict.Server.Owin
response.Redirect(builder.ToString()); response.Redirect(builder.ToString());
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
static bool Contains(StringBuilder builder, char delimiter) static bool Contains(StringBuilder builder, char delimiter)
{ {
@ -601,9 +601,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -620,7 +620,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.RedirectUri)) if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.RedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// Don't return the state originally sent by the client application. // Don't return the state originally sent by the client application.
@ -631,7 +631,7 @@ namespace OpenIddict.Server.Owin
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -656,9 +656,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public async ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {

6
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs

@ -66,9 +66,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -100,7 +100,7 @@ namespace OpenIddict.Server.Owin
context.Issuer = issuer; context.Issuer = issuer;
} }
return Task.CompletedTask; return default;
} }
} }
} }

6
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs

@ -55,9 +55,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleTokenRequestContext context) public ValueTask HandleAsync([NotNull] HandleTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -66,7 +66,7 @@ namespace OpenIddict.Server.Owin
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
} }

12
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Serialization.cs

@ -59,9 +59,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -93,7 +93,7 @@ namespace OpenIddict.Server.Owin
context.Issuer = issuer; context.Issuer = issuer;
} }
return Task.CompletedTask; return default;
} }
} }
@ -119,9 +119,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -153,7 +153,7 @@ namespace OpenIddict.Server.Owin
context.TokenValidationParameters.ValidIssuer = issuer.AbsoluteUri; context.TokenValidationParameters.ValidIssuer = issuer.AbsoluteUri;
} }
return Task.CompletedTask; return default;
} }
} }
} }

50
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs

@ -88,9 +88,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractLogoutRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -175,9 +175,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ExtractLogoutRequestContext context) public async ValueTask HandleAsync([NotNull] ExtractLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -257,9 +257,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleLogoutRequestContext context) public ValueTask HandleAsync([NotNull] HandleLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -268,7 +268,7 @@ namespace OpenIddict.Server.Owin
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -306,9 +306,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -317,7 +317,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.Request?.RequestId)) if (string.IsNullOrEmpty(context.Request?.RequestId))
{ {
return Task.CompletedTask; return default;
} }
// Note: the ApplyLogoutResponse event is called for both successful // Note: the ApplyLogoutResponse event is called for both successful
@ -326,7 +326,7 @@ namespace OpenIddict.Server.Owin
// Note: the cache key is always prefixed with a specific marker // Note: the cache key is always prefixed with a specific marker
// to avoid collisions with the other types of cached payloads. // to avoid collisions with the other types of cached payloads.
return _cache.RemoveAsync(Cache.LogoutRequest + context.Request.RequestId); return new ValueTask(_cache.RemoveAsync(Cache.LogoutRequest + context.Request.RequestId));
} }
} }
@ -351,9 +351,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -370,13 +370,13 @@ namespace OpenIddict.Server.Owin
if (!string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (!string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The logout response was successfully returned: {Response}.", response); context.Logger.LogInformation("The logout response was successfully returned: {Response}.", response);
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -401,9 +401,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -420,7 +420,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
context.Logger.LogInformation("The logout response was successfully returned to '{PostLogoutRedirectUri}': {Response}.", context.Logger.LogInformation("The logout response was successfully returned to '{PostLogoutRedirectUri}': {Response}.",
@ -439,7 +439,7 @@ namespace OpenIddict.Server.Owin
response.Redirect(location); response.Redirect(location);
context.HandleRequest(); context.HandleRequest();
return Task.CompletedTask; return default;
} }
} }
@ -467,9 +467,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -486,7 +486,7 @@ namespace OpenIddict.Server.Owin
if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (string.IsNullOrEmpty(context.Response.Error) || !string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// Apply a 400 status code by default. // Apply a 400 status code by default.
@ -494,7 +494,7 @@ namespace OpenIddict.Server.Owin
context.SkipRequest(); context.SkipRequest();
return Task.CompletedTask; return default;
} }
} }
@ -519,9 +519,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public async ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {

60
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs

@ -62,9 +62,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessRequestContext context) public ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -90,7 +90,7 @@ namespace OpenIddict.Server.Owin
Matches(context.Options.UserinfoEndpointUris) ? OpenIddictServerEndpointType.Userinfo : Matches(context.Options.UserinfoEndpointUris) ? OpenIddictServerEndpointType.Userinfo :
OpenIddictServerEndpointType.Unknown; OpenIddictServerEndpointType.Unknown;
return Task.CompletedTask; return default;
bool Matches(IList<Uri> addresses) bool Matches(IList<Uri> addresses)
{ {
@ -155,9 +155,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessRequestContext context) public ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -175,7 +175,7 @@ namespace OpenIddict.Server.Owin
// Don't require that the host be present if the request is not handled by OpenIddict. // Don't require that the host be present if the request is not handled by OpenIddict.
if (context.EndpointType == OpenIddictServerEndpointType.Unknown) if (context.EndpointType == OpenIddictServerEndpointType.Unknown)
{ {
return Task.CompletedTask; return default;
} }
// Reject authorization requests sent without transport security. // Reject authorization requests sent without transport security.
@ -185,10 +185,10 @@ namespace OpenIddict.Server.Owin
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "This server only accepts HTTPS requests."); description: "This server only accepts HTTPS requests.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -213,9 +213,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessRequestContext context) public ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -234,7 +234,7 @@ namespace OpenIddict.Server.Owin
// by an OpenIddict endpoint or if an explicit issuer URL was set in the options. // by an OpenIddict endpoint or if an explicit issuer URL was set in the options.
if (context.Options.Issuer != null || context.EndpointType == OpenIddictServerEndpointType.Unknown) if (context.Options.Issuer != null || context.EndpointType == OpenIddictServerEndpointType.Unknown)
{ {
return Task.CompletedTask; return default;
} }
if (string.IsNullOrEmpty(request.Host.Value)) if (string.IsNullOrEmpty(request.Host.Value))
@ -243,10 +243,10 @@ namespace OpenIddict.Server.Owin
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'Host' header is missing."); description: "The mandatory 'Host' header is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -271,9 +271,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -302,10 +302,10 @@ namespace OpenIddict.Server.Owin
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified HTTP method is not valid."); description: "The specified HTTP method is not valid.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -330,9 +330,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -417,9 +417,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -500,9 +500,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -520,7 +520,7 @@ namespace OpenIddict.Server.Owin
var header = request.Headers["Authorization"]; var header = request.Headers["Authorization"];
if (string.IsNullOrEmpty(header) || !header.StartsWith("Basic ", StringComparison.OrdinalIgnoreCase)) if (string.IsNullOrEmpty(header) || !header.StartsWith("Basic ", StringComparison.OrdinalIgnoreCase))
{ {
return Task.CompletedTask; return default;
} }
// At this point, reject requests that use multiple client authentication methods. // At this point, reject requests that use multiple client authentication methods.
@ -533,7 +533,7 @@ namespace OpenIddict.Server.Owin
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "Multiple client credentials cannot be specified."); description: "Multiple client credentials cannot be specified.");
return Task.CompletedTask; return default;
} }
try try
@ -548,14 +548,14 @@ namespace OpenIddict.Server.Owin
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified client credentials are invalid."); description: "The specified client credentials are invalid.");
return Task.CompletedTask; return default;
} }
// Attach the basic authentication credentials to the request message. // Attach the basic authentication credentials to the request message.
context.Request.ClientId = UnescapeDataString(data.Substring(0, index)); context.Request.ClientId = UnescapeDataString(data.Substring(0, index));
context.Request.ClientSecret = UnescapeDataString(data.Substring(index + 1)); context.Request.ClientSecret = UnescapeDataString(data.Substring(index + 1));
return Task.CompletedTask; return default;
} }
catch catch
@ -564,7 +564,7 @@ namespace OpenIddict.Server.Owin
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified client credentials are invalid."); description: "The specified client credentials are invalid.");
return Task.CompletedTask; return default;
} }
static string UnescapeDataString(string data) static string UnescapeDataString(string data)
@ -600,9 +600,9 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {

2
src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs

@ -37,7 +37,7 @@ namespace OpenIddict.Server.Owin
/// </summary> /// </summary>
/// <param name="context">The <see cref="IOwinContext"/>.</param> /// <param name="context">The <see cref="IOwinContext"/>.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public override Task Invoke([NotNull] IOwinContext context) public override Task Invoke([NotNull] IOwinContext context)
{ {

4
src/OpenIddict.Server/IOpenIddictServerHandler.cs

@ -21,8 +21,8 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
Task HandleAsync([NotNull] TContext context); ValueTask HandleAsync([NotNull] TContext context);
} }
} }

2
src/OpenIddict.Server/IOpenIddictServerHandlerFilter.cs

@ -12,6 +12,6 @@ namespace OpenIddict.Server
{ {
public interface IOpenIddictServerHandlerFilter<in TContext> where TContext : BaseContext public interface IOpenIddictServerHandlerFilter<in TContext> where TContext : BaseContext
{ {
Task<bool> IsActiveAsync([NotNull] TContext context); ValueTask<bool> IsActiveAsync([NotNull] TContext context);
} }
} }

2
src/OpenIddict.Server/IOpenIddictServerProvider.cs

@ -13,6 +13,6 @@ namespace OpenIddict.Server
public interface IOpenIddictServerProvider public interface IOpenIddictServerProvider
{ {
ValueTask<OpenIddictServerTransaction> CreateTransactionAsync(); ValueTask<OpenIddictServerTransaction> CreateTransactionAsync();
Task DispatchAsync<TContext>([NotNull] TContext context) where TContext : BaseContext; ValueTask DispatchAsync<TContext>([NotNull] TContext context) where TContext : BaseContext;
} }
} }

8
src/OpenIddict.Server/OpenIddictServerHandler.cs

@ -17,13 +17,13 @@ namespace OpenIddict.Server
/// <typeparam name="TContext">The type of the events handled by this instance.</typeparam> /// <typeparam name="TContext">The type of the events handled by this instance.</typeparam>
public class OpenIddictServerHandler<TContext> : IOpenIddictServerHandler<TContext> where TContext : BaseContext public class OpenIddictServerHandler<TContext> : IOpenIddictServerHandler<TContext> where TContext : BaseContext
{ {
private readonly Func<TContext, Task> _handler; private readonly Func<TContext, ValueTask> _handler;
/// <summary> /// <summary>
/// Creates a new event using the specified handler delegate. /// Creates a new event using the specified handler delegate.
/// </summary> /// </summary>
/// <param name="handler">The event handler delegate.</param> /// <param name="handler">The event handler delegate.</param>
public OpenIddictServerHandler([NotNull] Func<TContext, Task> handler) public OpenIddictServerHandler([NotNull] Func<TContext, ValueTask> handler)
=> _handler = handler ?? throw new ArgumentNullException(nameof(handler)); => _handler = handler ?? throw new ArgumentNullException(nameof(handler));
/// <summary> /// <summary>
@ -31,9 +31,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The event to process.</param> /// <param name="context">The event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
=> _handler(context ?? throw new ArgumentNullException(nameof(context))); => _handler(context ?? throw new ArgumentNullException(nameof(context)));
} }
} }

2
src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs

@ -136,7 +136,7 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="handler">The handler instance.</param> /// <param name="handler">The handler instance.</param>
/// <returns>The builder instance, so that calls can be easily chained.</returns> /// <returns>The builder instance, so that calls can be easily chained.</returns>
public Builder<TContext> UseInlineHandler([NotNull] Func<TContext, Task> handler) public Builder<TContext> UseInlineHandler([NotNull] Func<TContext, ValueTask> handler)
{ {
if (handler == null) if (handler == null)
{ {

48
src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs

@ -20,14 +20,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireAccessTokenIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext> public class RequireAccessTokenIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context) public ValueTask<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.IncludeAccessToken); return new ValueTask<bool>(context.IncludeAccessToken);
} }
} }
@ -36,14 +36,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireAuthorizationCodeIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext> public class RequireAuthorizationCodeIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context) public ValueTask<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.IncludeAuthorizationCode); return new ValueTask<bool>(context.IncludeAuthorizationCode);
} }
} }
@ -52,14 +52,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireClientIdParameter : IOpenIddictServerHandlerFilter<BaseContext> public class RequireClientIdParameter : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!string.IsNullOrEmpty(context.Request.ClientId)); return new ValueTask<bool>(!string.IsNullOrEmpty(context.Request.ClientId));
} }
} }
@ -68,14 +68,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireDegradedModeDisabled : IOpenIddictServerHandlerFilter<BaseContext> public class RequireDegradedModeDisabled : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!context.Options.EnableDegradedMode); return new ValueTask<bool>(!context.Options.EnableDegradedMode);
} }
} }
@ -84,14 +84,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireDegradedModeEnabled : IOpenIddictServerHandlerFilter<BaseContext> public class RequireDegradedModeEnabled : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.Options.EnableDegradedMode); return new ValueTask<bool>(context.Options.EnableDegradedMode);
} }
} }
@ -100,14 +100,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireEndpointPermissionsEnabled : IOpenIddictServerHandlerFilter<BaseContext> public class RequireEndpointPermissionsEnabled : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!context.Options.IgnoreEndpointPermissions); return new ValueTask<bool>(!context.Options.IgnoreEndpointPermissions);
} }
} }
@ -116,14 +116,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireGrantTypePermissionsEnabled : IOpenIddictServerHandlerFilter<BaseContext> public class RequireGrantTypePermissionsEnabled : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!context.Options.IgnoreGrantTypePermissions); return new ValueTask<bool>(!context.Options.IgnoreGrantTypePermissions);
} }
} }
@ -132,14 +132,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireIdentityTokenIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext> public class RequireIdentityTokenIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context) public ValueTask<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.IncludeIdentityToken); return new ValueTask<bool>(context.IncludeIdentityToken);
} }
} }
@ -148,14 +148,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequirePostLogoutRedirectUriParameter : IOpenIddictServerHandlerFilter<BaseContext> public class RequirePostLogoutRedirectUriParameter : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!string.IsNullOrEmpty(context.Request.PostLogoutRedirectUri)); return new ValueTask<bool>(!string.IsNullOrEmpty(context.Request.PostLogoutRedirectUri));
} }
} }
@ -164,14 +164,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireRefreshTokenIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext> public class RequireRefreshTokenIncluded : IOpenIddictServerHandlerFilter<ProcessSigninResponseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context) public ValueTask<bool> IsActiveAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(context.IncludeRefreshToken); return new ValueTask<bool>(context.IncludeRefreshToken);
} }
} }
@ -180,14 +180,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireScopePermissionsEnabled : IOpenIddictServerHandlerFilter<BaseContext> public class RequireScopePermissionsEnabled : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!context.Options.IgnoreScopePermissions); return new ValueTask<bool>(!context.Options.IgnoreScopePermissions);
} }
} }
@ -196,14 +196,14 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
public class RequireScopeValidationEnabled : IOpenIddictServerHandlerFilter<BaseContext> public class RequireScopeValidationEnabled : IOpenIddictServerHandlerFilter<BaseContext>
{ {
public Task<bool> IsActiveAsync([NotNull] BaseContext context) public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context)
{ {
if (context == null) if (context == null)
{ {
throw new ArgumentNullException(nameof(context)); throw new ArgumentNullException(nameof(context));
} }
return Task.FromResult(!context.Options.DisableScopeValidation); return new ValueTask<bool>(!context.Options.DisableScopeValidation);
} }
} }
} }

170
src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs

@ -84,9 +84,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -159,9 +159,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -233,9 +233,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -327,9 +327,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -377,9 +377,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -396,10 +396,10 @@ namespace OpenIddict.Server
error: Errors.RequestNotSupported, error: Errors.RequestNotSupported,
description: "The 'request' parameter is not supported."); description: "The 'request' parameter is not supported.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -422,9 +422,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -441,10 +441,10 @@ namespace OpenIddict.Server
error: Errors.RequestUriNotSupported, error: Errors.RequestUriNotSupported,
description: "The 'request_uri' parameter is not supported."); description: "The 'request_uri' parameter is not supported.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -467,9 +467,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -487,10 +487,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'client_id' parameter is missing."); description: "The mandatory 'client_id' parameter is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -513,9 +513,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -538,10 +538,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'redirect_uri' parameter is missing."); description: "The mandatory 'redirect_uri' parameter is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
// Note: when specified, redirect_uri MUST be an absolute URI. // Note: when specified, redirect_uri MUST be an absolute URI.
@ -561,7 +561,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'redirect_uri' parameter must be a valid absolute URL."); description: "The 'redirect_uri' parameter must be a valid absolute URL.");
return Task.CompletedTask; return default;
} }
// Note: when specified, redirect_uri MUST NOT include a fragment component. // Note: when specified, redirect_uri MUST NOT include a fragment component.
@ -576,10 +576,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'redirect_uri' parameter must not include a fragment."); description: "The 'redirect_uri' parameter must not include a fragment.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -602,9 +602,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -621,7 +621,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'response_type' parameter is missing."); description: "The mandatory 'response_type' parameter is missing.");
return Task.CompletedTask; return default;
} }
// Reject requests containing the id_token response_type if no openid scope has been received. // Reject requests containing the id_token response_type if no openid scope has been received.
@ -633,7 +633,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'openid' scope is missing."); description: "The mandatory 'openid' scope is missing.");
return Task.CompletedTask; return default;
} }
// Reject requests containing the code response_type if the token endpoint has been disabled. // Reject requests containing the code response_type if the token endpoint has been disabled.
@ -645,7 +645,7 @@ namespace OpenIddict.Server
error: Errors.UnsupportedResponseType, error: Errors.UnsupportedResponseType,
description: "The specified 'response_type' is not supported by this server."); description: "The specified 'response_type' is not supported by this server.");
return Task.CompletedTask; return default;
} }
// Reject requests that specify an unsupported response_type. // Reject requests that specify an unsupported response_type.
@ -658,7 +658,7 @@ namespace OpenIddict.Server
error: Errors.UnsupportedResponseType, error: Errors.UnsupportedResponseType,
description: "The specified 'response_type' parameter is not supported."); description: "The specified 'response_type' parameter is not supported.");
return Task.CompletedTask; return default;
} }
// Reject code flow authorization requests if the authorization code flow is not enabled. // Reject code flow authorization requests if the authorization code flow is not enabled.
@ -671,7 +671,7 @@ namespace OpenIddict.Server
error: Errors.UnsupportedResponseType, error: Errors.UnsupportedResponseType,
description: "The specified 'response_type' parameter is not allowed."); description: "The specified 'response_type' parameter is not allowed.");
return Task.CompletedTask; return default;
} }
// Reject implicit flow authorization requests if the implicit flow is not enabled. // Reject implicit flow authorization requests if the implicit flow is not enabled.
@ -683,7 +683,7 @@ namespace OpenIddict.Server
error: Errors.UnsupportedResponseType, error: Errors.UnsupportedResponseType,
description: "The specified 'response_type' parameter is not allowed."); description: "The specified 'response_type' parameter is not allowed.");
return Task.CompletedTask; return default;
} }
// Reject hybrid flow authorization requests if the authorization code or the implicit flows are not enabled. // Reject hybrid flow authorization requests if the authorization code or the implicit flows are not enabled.
@ -697,7 +697,7 @@ namespace OpenIddict.Server
error: Errors.UnsupportedResponseType, error: Errors.UnsupportedResponseType,
description: "The specified 'response_type' parameter is not allowed."); description: "The specified 'response_type' parameter is not allowed.");
return Task.CompletedTask; return default;
} }
// Reject authorization requests that specify scope=offline_access if the refresh token flow is not enabled. // Reject authorization requests that specify scope=offline_access if the refresh token flow is not enabled.
@ -707,10 +707,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'offline_access' scope is not allowed."); description: "The 'offline_access' scope is not allowed.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -733,9 +733,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -756,7 +756,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified 'response_type'/'response_mode' combination is invalid."); description: "The specified 'response_type'/'response_mode' combination is invalid.");
return Task.CompletedTask; return default;
} }
// Reject requests that specify an unsupported response_mode. // Reject requests that specify an unsupported response_mode.
@ -771,10 +771,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified 'response_mode' parameter is not supported."); description: "The specified 'response_mode' parameter is not supported.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -797,9 +797,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -813,7 +813,7 @@ namespace OpenIddict.Server
if (!string.IsNullOrEmpty(context.Request.Nonce) || !context.Request.HasScope(Scopes.OpenId)) if (!string.IsNullOrEmpty(context.Request.Nonce) || !context.Request.HasScope(Scopes.OpenId))
{ {
return Task.CompletedTask; return default;
} }
if (context.Request.IsImplicitFlow() || context.Request.IsHybridFlow()) if (context.Request.IsImplicitFlow() || context.Request.IsHybridFlow())
@ -824,10 +824,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'nonce' parameter is missing."); description: "The mandatory 'nonce' parameter is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -850,9 +850,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -870,10 +870,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified 'prompt' parameter is invalid."); description: "The specified 'prompt' parameter is invalid.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -896,9 +896,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -908,7 +908,7 @@ namespace OpenIddict.Server
if (string.IsNullOrEmpty(context.Request.CodeChallenge) && if (string.IsNullOrEmpty(context.Request.CodeChallenge) &&
string.IsNullOrEmpty(context.Request.CodeChallengeMethod)) string.IsNullOrEmpty(context.Request.CodeChallengeMethod))
{ {
return Task.CompletedTask; return default;
} }
// Ensure a code_challenge was specified if a code_challenge_method was used. // Ensure a code_challenge was specified if a code_challenge_method was used.
@ -920,7 +920,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'code_challenge_method' parameter cannot be used without 'code_challenge'."); description: "The 'code_challenge_method' parameter cannot be used without 'code_challenge'.");
return Task.CompletedTask; return default;
} }
// When code_challenge or code_challenge_method is specified, ensure the response_type includes "code". // When code_challenge or code_challenge_method is specified, ensure the response_type includes "code".
@ -934,7 +934,7 @@ namespace OpenIddict.Server
description: "The 'code_challenge' and 'code_challenge_method' parameters " + description: "The 'code_challenge' and 'code_challenge_method' parameters " +
"can only be used with a response type containing 'code'."); "can only be used with a response type containing 'code'.");
return Task.CompletedTask; return default;
} }
// Reject authorization requests that contain response_type=token when a code_challenge is specified. // Reject authorization requests that contain response_type=token when a code_challenge is specified.
@ -947,7 +947,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified 'response_type' parameter is not allowed when using PKCE."); description: "The specified 'response_type' parameter is not allowed when using PKCE.");
return Task.CompletedTask; return default;
} }
// If a code_challenge_method was specified, ensure the algorithm is supported. // If a code_challenge_method was specified, ensure the algorithm is supported.
@ -962,10 +962,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The specified code_challenge_method is not supported'."); description: "The specified code_challenge_method is not supported'.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -1004,9 +1004,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1072,9 +1072,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1131,9 +1131,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1198,9 +1198,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1263,9 +1263,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1328,9 +1328,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1438,9 +1438,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateAuthorizationRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateAuthorizationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1498,9 +1498,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1509,7 +1509,7 @@ namespace OpenIddict.Server
if (context.Request == null) if (context.Request == null)
{ {
return Task.CompletedTask; return default;
} }
// Note: at this stage, the validated redirect URI property may be null (e.g if an error // Note: at this stage, the validated redirect URI property may be null (e.g if an error
@ -1519,7 +1519,7 @@ namespace OpenIddict.Server
context.RedirectUri = (string) property; context.RedirectUri = (string) property;
} }
return Task.CompletedTask; return default;
} }
} }
@ -1543,9 +1543,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1554,7 +1554,7 @@ namespace OpenIddict.Server
if (context.Request == null) if (context.Request == null)
{ {
return Task.CompletedTask; return default;
} }
context.ResponseMode = context.Request.ResponseMode; context.ResponseMode = context.Request.ResponseMode;
@ -1567,7 +1567,7 @@ namespace OpenIddict.Server
context.Request.IsQueryResponseMode() ? ResponseModes.Query : null; context.Request.IsQueryResponseMode() ? ResponseModes.Query : null;
} }
return Task.CompletedTask; return default;
} }
} }
@ -1590,9 +1590,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyAuthorizationResponseContext context) public ValueTask HandleAsync([NotNull] ApplyAuthorizationResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1605,7 +1605,7 @@ namespace OpenIddict.Server
context.Response.State = context.Request?.State; context.Response.State = context.Request?.State;
} }
return Task.CompletedTask; return default;
} }
} }
} }

110
src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs

@ -91,9 +91,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -166,9 +166,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -232,9 +232,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -326,9 +326,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -376,9 +376,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -390,7 +390,7 @@ namespace OpenIddict.Server
context.Issuer = context.Options.Issuer; context.Issuer = context.Options.Issuer;
} }
return Task.CompletedTask; return default;
} }
} }
@ -413,9 +413,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -505,7 +505,7 @@ namespace OpenIddict.Server
context.UserinfoEndpoint = new Uri(context.Issuer, context.UserinfoEndpoint); context.UserinfoEndpoint = new Uri(context.Issuer, context.UserinfoEndpoint);
} }
return Task.CompletedTask; return default;
} }
} }
@ -528,9 +528,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -543,7 +543,7 @@ namespace OpenIddict.Server
context.GrantTypes.UnionWith(context.Options.GrantTypes); context.GrantTypes.UnionWith(context.Options.GrantTypes);
} }
return Task.CompletedTask; return default;
} }
} }
@ -566,9 +566,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -583,7 +583,7 @@ namespace OpenIddict.Server
context.ResponseModes.Add(ResponseModes.Query); context.ResponseModes.Add(ResponseModes.Query);
} }
return Task.CompletedTask; return default;
} }
} }
@ -606,9 +606,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -635,7 +635,7 @@ namespace OpenIddict.Server
context.ResponseTypes.Add(ResponseTypes.Token); context.ResponseTypes.Add(ResponseTypes.Token);
} }
return Task.CompletedTask; return default;
} }
} }
@ -659,9 +659,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -686,7 +686,7 @@ namespace OpenIddict.Server
context.TokenEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretPost); context.TokenEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretPost);
} }
return Task.CompletedTask; return default;
} }
} }
@ -710,9 +710,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -728,7 +728,7 @@ namespace OpenIddict.Server
context.CodeChallengeMethods.Add(CodeChallengeMethods.Sha256); context.CodeChallengeMethods.Add(CodeChallengeMethods.Sha256);
} }
return Task.CompletedTask; return default;
} }
} }
@ -751,9 +751,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -762,7 +762,7 @@ namespace OpenIddict.Server
context.Scopes.UnionWith(context.Options.Scopes); context.Scopes.UnionWith(context.Options.Scopes);
return Task.CompletedTask; return default;
} }
} }
@ -785,9 +785,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -796,7 +796,7 @@ namespace OpenIddict.Server
context.Claims.UnionWith(context.Options.Claims); context.Claims.UnionWith(context.Options.Claims);
return Task.CompletedTask; return default;
} }
} }
@ -819,9 +819,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -830,7 +830,7 @@ namespace OpenIddict.Server
context.SubjectTypes.Add(SubjectTypes.Public); context.SubjectTypes.Add(SubjectTypes.Public);
return Task.CompletedTask; return default;
} }
} }
@ -853,9 +853,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -914,7 +914,7 @@ namespace OpenIddict.Server
context.IdTokenSigningAlgorithms.Add(algorithm); context.IdTokenSigningAlgorithms.Add(algorithm);
} }
return Task.CompletedTask; return default;
} }
} }
@ -937,9 +937,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleConfigurationRequestContext context) public ValueTask HandleAsync([NotNull] HandleConfigurationRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -952,7 +952,7 @@ namespace OpenIddict.Server
context.Metadata[Metadata.RequestParameterSupported] = false; context.Metadata[Metadata.RequestParameterSupported] = false;
context.Metadata[Metadata.RequestUriParameterSupported] = false; context.Metadata[Metadata.RequestUriParameterSupported] = false;
return Task.CompletedTask; return default;
} }
} }
@ -980,9 +980,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1055,9 +1055,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1121,9 +1121,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1247,9 +1247,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1297,9 +1297,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleCryptographyRequestContext context) public ValueTask HandleAsync([NotNull] HandleCryptographyRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1465,7 +1465,7 @@ namespace OpenIddict.Server
context.Keys.Add(key); context.Keys.Add(key);
} }
return Task.CompletedTask; return default;
static bool IsAlgorithmSupported(SecurityKey key, string algorithm) => static bool IsAlgorithmSupported(SecurityKey key, string algorithm) =>
key.CryptoProviderFactory.IsSupportedAlgorithm(algorithm, key); key.CryptoProviderFactory.IsSupportedAlgorithm(algorithm, key);

168
src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs

@ -89,9 +89,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -164,9 +164,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -233,9 +233,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -327,9 +327,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -377,9 +377,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -395,7 +395,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'grant_type' parameter is missing."); description: "The mandatory 'grant_type' parameter is missing.");
return Task.CompletedTask; return default;
} }
// Reject token requests that don't specify a supported grant type. // Reject token requests that don't specify a supported grant type.
@ -408,7 +408,7 @@ namespace OpenIddict.Server
error: Errors.UnsupportedGrantType, error: Errors.UnsupportedGrantType,
description: "The specified 'grant_type' parameter is not supported."); description: "The specified 'grant_type' parameter is not supported.");
return Task.CompletedTask; return default;
} }
// Reject token requests that specify scope=offline_access if the refresh token flow is not enabled. // Reject token requests that specify scope=offline_access if the refresh token flow is not enabled.
@ -419,10 +419,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'offline_access' scope is not allowed."); description: "The 'offline_access' scope is not allowed.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -446,9 +446,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -457,7 +457,7 @@ namespace OpenIddict.Server
if (!string.IsNullOrEmpty(context.ClientId)) if (!string.IsNullOrEmpty(context.ClientId))
{ {
return Task.CompletedTask; return default;
} }
// At this stage, reject the token request unless the client identification requirement was disabled. // At this stage, reject the token request unless the client identification requirement was disabled.
@ -473,10 +473,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'client_id' parameter is missing."); description: "The mandatory 'client_id' parameter is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -500,9 +500,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -519,10 +519,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'code' parameter is missing."); description: "The mandatory 'code' parameter is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -546,9 +546,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -565,10 +565,10 @@ namespace OpenIddict.Server
description: "The 'client_id' and 'client_secret' parameters are " + description: "The 'client_id' and 'client_secret' parameters are " +
"required when using the client credentials grant."); "required when using the client credentials grant.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -592,9 +592,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -611,10 +611,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'refresh_token' parameter is missing."); description: "The mandatory 'refresh_token' parameter is missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -638,9 +638,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -658,10 +658,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'username' and/or 'password' parameters are missing."); description: "The mandatory 'username' and/or 'password' parameters are missing.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -700,9 +700,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -769,9 +769,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -831,9 +831,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -927,9 +927,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -995,9 +995,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1062,9 +1062,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1144,9 +1144,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1212,9 +1212,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1294,9 +1294,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateTokenRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1372,9 +1372,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1383,7 +1383,7 @@ namespace OpenIddict.Server
if (!context.Request.IsAuthorizationCodeGrantType() && !context.Request.IsRefreshTokenGrantType()) if (!context.Request.IsAuthorizationCodeGrantType() && !context.Request.IsRefreshTokenGrantType())
{ {
return Task.CompletedTask; return default;
} }
var presenters = context.Principal.GetPresenters(); var presenters = context.Principal.GetPresenters();
@ -1396,7 +1396,7 @@ namespace OpenIddict.Server
throw new InvalidOperationException("The presenters list cannot be extracted from the authorization code."); throw new InvalidOperationException("The presenters list cannot be extracted from the authorization code.");
} }
return Task.CompletedTask; return default;
} }
// If at least one presenter was associated to the authorization code/refresh token, // If at least one presenter was associated to the authorization code/refresh token,
@ -1413,7 +1413,7 @@ namespace OpenIddict.Server
"The specified authorization code cannot be used without specifying a client identifier." : "The specified authorization code cannot be used without specifying a client identifier." :
"The specified refresh token cannot be used without specifying a client identifier."); "The specified refresh token cannot be used without specifying a client identifier.");
return Task.CompletedTask; return default;
} }
// Ensure the authorization code/refresh token was issued to the client application making the token request. // Ensure the authorization code/refresh token was issued to the client application making the token request.
@ -1431,10 +1431,10 @@ namespace OpenIddict.Server
"The specified authorization code cannot be used by this client application." : "The specified authorization code cannot be used by this client application." :
"The specified refresh token cannot be used by this client application."); "The specified refresh token cannot be used by this client application.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -1457,9 +1457,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1468,7 +1468,7 @@ namespace OpenIddict.Server
if (!context.Request.IsAuthorizationCodeGrantType()) if (!context.Request.IsAuthorizationCodeGrantType())
{ {
return Task.CompletedTask; return default;
} }
// Validate the redirect_uri sent by the client application as part of this token request. // Validate the redirect_uri sent by the client application as part of this token request.
@ -1481,7 +1481,7 @@ namespace OpenIddict.Server
var address = context.Principal.GetClaim(Claims.Private.OriginalRedirectUri); var address = context.Principal.GetClaim(Claims.Private.OriginalRedirectUri);
if (string.IsNullOrEmpty(address)) if (string.IsNullOrEmpty(address))
{ {
return Task.CompletedTask; return default;
} }
if (string.IsNullOrEmpty(context.Request.RedirectUri)) if (string.IsNullOrEmpty(context.Request.RedirectUri))
@ -1493,7 +1493,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'redirect_uri' parameter is missing."); description: "The mandatory 'redirect_uri' parameter is missing.");
return Task.CompletedTask; return default;
} }
if (!string.Equals(address, context.Request.RedirectUri, StringComparison.Ordinal)) if (!string.Equals(address, context.Request.RedirectUri, StringComparison.Ordinal))
@ -1506,10 +1506,10 @@ namespace OpenIddict.Server
description: "The specified 'redirect_uri' parameter doesn't match the client " + description: "The specified 'redirect_uri' parameter doesn't match the client " +
"redirection endpoint the authorization code was initially sent to."); "redirection endpoint the authorization code was initially sent to.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -1532,9 +1532,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1543,7 +1543,7 @@ namespace OpenIddict.Server
if (!context.Request.IsAuthorizationCodeGrantType()) if (!context.Request.IsAuthorizationCodeGrantType())
{ {
return Task.CompletedTask; return default;
} }
// If a code challenge was initially sent in the authorization request and associated with the // If a code challenge was initially sent in the authorization request and associated with the
@ -1551,7 +1551,7 @@ namespace OpenIddict.Server
var challenge = context.Principal.GetClaim(Claims.Private.CodeChallenge); var challenge = context.Principal.GetClaim(Claims.Private.CodeChallenge);
if (string.IsNullOrEmpty(challenge)) if (string.IsNullOrEmpty(challenge))
{ {
return Task.CompletedTask; return default;
} }
// Get the code verifier from the token request. // Get the code verifier from the token request.
@ -1565,7 +1565,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The mandatory 'code_verifier' parameter is missing."); description: "The mandatory 'code_verifier' parameter is missing.");
return Task.CompletedTask; return default;
} }
// If no code challenge method was specified, default to S256. // If no code challenge method was specified, default to S256.
@ -1597,7 +1597,7 @@ namespace OpenIddict.Server
error: Errors.InvalidGrant, error: Errors.InvalidGrant,
description: "The specified 'code_challenge_method' is invalid."); description: "The specified 'code_challenge_method' is invalid.");
return Task.CompletedTask; return default;
} }
// Compare the verifier and the code challenge: if the two don't match, return an error. // Compare the verifier and the code challenge: if the two don't match, return an error.
@ -1610,10 +1610,10 @@ namespace OpenIddict.Server
error: Errors.InvalidGrant, error: Errors.InvalidGrant,
description: "The specified 'code_verifier' parameter is invalid."); description: "The specified 'code_verifier' parameter is invalid.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
@ -1659,7 +1659,7 @@ namespace OpenIddict.Server
.SetOrder(ValidateCodeVerifier.Descriptor.Order + 1_000) .SetOrder(ValidateCodeVerifier.Descriptor.Order + 1_000)
.Build(); .Build();
public Task HandleAsync([NotNull] ValidateTokenRequestContext context) public ValueTask HandleAsync([NotNull] ValidateTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1668,7 +1668,7 @@ namespace OpenIddict.Server
if (!context.Request.IsAuthorizationCodeGrantType() || string.IsNullOrEmpty(context.Request.Scope)) if (!context.Request.IsAuthorizationCodeGrantType() || string.IsNullOrEmpty(context.Request.Scope))
{ {
return Task.CompletedTask; return default;
} }
// When an explicit scope parameter has been included in the token request // When an explicit scope parameter has been included in the token request
@ -1683,7 +1683,7 @@ namespace OpenIddict.Server
error: Errors.InvalidGrant, error: Errors.InvalidGrant,
description: "The 'scope' parameter is not valid in this context."); description: "The 'scope' parameter is not valid in this context.");
return Task.CompletedTask; return default;
} }
// When an explicit scope parameter has been included in the token request, // When an explicit scope parameter has been included in the token request,
@ -1698,10 +1698,10 @@ namespace OpenIddict.Server
error: Errors.InvalidGrant, error: Errors.InvalidGrant,
description: "The specified 'scope' parameter is invalid."); description: "The specified 'scope' parameter is invalid.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -1725,9 +1725,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] HandleTokenRequestContext context) public ValueTask HandleAsync([NotNull] HandleTokenRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -1736,7 +1736,7 @@ namespace OpenIddict.Server
if (!context.Request.IsAuthorizationCodeGrantType() && !context.Request.IsRefreshTokenGrantType()) if (!context.Request.IsAuthorizationCodeGrantType() && !context.Request.IsRefreshTokenGrantType())
{ {
return Task.CompletedTask; return default;
} }
if (context.Transaction.Properties.TryGetValue(Properties.OriginalPrincipal, out var principal)) if (context.Transaction.Properties.TryGetValue(Properties.OriginalPrincipal, out var principal))
@ -1744,7 +1744,7 @@ namespace OpenIddict.Server
context.Principal ??= (ClaimsPrincipal) principal; context.Principal ??= (ClaimsPrincipal) principal;
} }
return Task.CompletedTask; return default;
} }
} }
} }

66
src/OpenIddict.Server/OpenIddictServerHandlers.Serialization.cs

@ -95,9 +95,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -178,7 +178,7 @@ namespace OpenIddict.Server
context.HandleSerialization(); context.HandleSerialization();
return Task.CompletedTask; return default;
} }
} }
@ -201,9 +201,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] TContext context) public ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -214,7 +214,7 @@ namespace OpenIddict.Server
{ {
context.Logger.LogTrace("The token '{Token}' was not compatible with the JWT format.", context.Token); context.Logger.LogTrace("The token '{Token}' was not compatible with the JWT format.", context.Token);
return Task.CompletedTask; return default;
} }
try try
@ -241,7 +241,7 @@ namespace OpenIddict.Server
context.Logger.LogDebug("The token usage associated to the token {Token} does not match the expected type."); context.Logger.LogDebug("The token usage associated to the token {Token} does not match the expected type.");
context.HandleDeserialization(); context.HandleDeserialization();
return Task.CompletedTask; return default;
} }
context.Principal = new ClaimsPrincipal(result.ClaimsIdentity); context.Principal = new ClaimsPrincipal(result.ClaimsIdentity);
@ -260,7 +260,7 @@ namespace OpenIddict.Server
context.HandleDeserialization(); context.HandleDeserialization();
return Task.CompletedTask; return default;
} }
catch (Exception exception) catch (Exception exception)
@ -268,7 +268,7 @@ namespace OpenIddict.Server
context.Logger.LogDebug(exception, "An exception occured while deserializing a token."); context.Logger.LogDebug(exception, "An exception occured while deserializing a token.");
context.HandleDeserialization(); context.HandleDeserialization();
return Task.CompletedTask; return default;
} }
} }
} }
@ -292,9 +292,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeAccessTokenContext context) public ValueTask HandleAsync([NotNull] SerializeAccessTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -313,7 +313,7 @@ namespace OpenIddict.Server
context.SigningCredentials = context.Options.SigningCredentials.FirstOrDefault( context.SigningCredentials = context.Options.SigningCredentials.FirstOrDefault(
credentials => credentials.Key is SymmetricSecurityKey) ?? context.Options.SigningCredentials.First(); credentials => credentials.Key is SymmetricSecurityKey) ?? context.Options.SigningCredentials.First();
return Task.CompletedTask; return default;
} }
} }
@ -336,9 +336,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeAuthorizationCodeContext context) public ValueTask HandleAsync([NotNull] SerializeAuthorizationCodeContext context)
{ {
if (context == null) if (context == null)
{ {
@ -361,7 +361,7 @@ namespace OpenIddict.Server
context.SigningCredentials = context.Options.SigningCredentials.FirstOrDefault( context.SigningCredentials = context.Options.SigningCredentials.FirstOrDefault(
credentials => credentials.Key is SymmetricSecurityKey) ?? context.Options.SigningCredentials.First(); credentials => credentials.Key is SymmetricSecurityKey) ?? context.Options.SigningCredentials.First();
return Task.CompletedTask; return default;
} }
} }
@ -384,9 +384,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeIdentityTokenContext context) public ValueTask HandleAsync([NotNull] SerializeIdentityTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -403,7 +403,7 @@ namespace OpenIddict.Server
context.SigningCredentials = context.Options.SigningCredentials.First( context.SigningCredentials = context.Options.SigningCredentials.First(
credentials => credentials.Key is AsymmetricSecurityKey); credentials => credentials.Key is AsymmetricSecurityKey);
return Task.CompletedTask; return default;
} }
} }
@ -426,9 +426,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] SerializeRefreshTokenContext context) public ValueTask HandleAsync([NotNull] SerializeRefreshTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -451,7 +451,7 @@ namespace OpenIddict.Server
context.SigningCredentials = context.Options.SigningCredentials.FirstOrDefault( context.SigningCredentials = context.Options.SigningCredentials.FirstOrDefault(
credentials => credentials.Key is SymmetricSecurityKey) ?? context.Options.SigningCredentials.First(); credentials => credentials.Key is SymmetricSecurityKey) ?? context.Options.SigningCredentials.First();
return Task.CompletedTask; return default;
} }
} }
@ -474,9 +474,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeAccessTokenContext context) public ValueTask HandleAsync([NotNull] DeserializeAccessTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -496,7 +496,7 @@ namespace OpenIddict.Server
context.TokenValidationParameters.ValidateAudience = false; context.TokenValidationParameters.ValidateAudience = false;
context.TokenValidationParameters.ValidateLifetime = false; context.TokenValidationParameters.ValidateLifetime = false;
return Task.CompletedTask; return default;
} }
} }
@ -519,9 +519,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeAuthorizationCodeContext context) public ValueTask HandleAsync([NotNull] DeserializeAuthorizationCodeContext context)
{ {
if (context == null) if (context == null)
{ {
@ -540,7 +540,7 @@ namespace OpenIddict.Server
context.TokenValidationParameters.ValidateAudience = false; context.TokenValidationParameters.ValidateAudience = false;
context.TokenValidationParameters.ValidateLifetime = false; context.TokenValidationParameters.ValidateLifetime = false;
return Task.CompletedTask; return default;
} }
} }
@ -563,9 +563,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeIdentityTokenContext context) public ValueTask HandleAsync([NotNull] DeserializeIdentityTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -583,7 +583,7 @@ namespace OpenIddict.Server
context.TokenValidationParameters.ValidateAudience = false; context.TokenValidationParameters.ValidateAudience = false;
context.TokenValidationParameters.ValidateLifetime = false; context.TokenValidationParameters.ValidateLifetime = false;
return Task.CompletedTask; return default;
} }
} }
@ -606,9 +606,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] DeserializeRefreshTokenContext context) public ValueTask HandleAsync([NotNull] DeserializeRefreshTokenContext context)
{ {
if (context == null) if (context == null)
{ {
@ -627,7 +627,7 @@ namespace OpenIddict.Server
context.TokenValidationParameters.ValidateAudience = false; context.TokenValidationParameters.ValidateAudience = false;
context.TokenValidationParameters.ValidateLifetime = false; context.TokenValidationParameters.ValidateLifetime = false;
return Task.CompletedTask; return default;
} }
} }
} }

51
src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs

@ -68,9 +68,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -143,9 +143,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -215,9 +215,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessRequestContext context) public async ValueTask HandleAsync([NotNull] ProcessRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -308,9 +308,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] TContext context) public async ValueTask HandleAsync([NotNull] TContext context)
{ {
if (context == null) if (context == null)
{ {
@ -358,9 +358,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ValidateLogoutRequestContext context) public ValueTask HandleAsync([NotNull] ValidateLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -369,12 +369,11 @@ namespace OpenIddict.Server
if (string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (string.IsNullOrEmpty(context.PostLogoutRedirectUri))
{ {
return Task.CompletedTask; return default;
} }
// If an optional post_logout_redirect_uri was provided, validate it. // If an optional post_logout_redirect_uri was provided, validate it.
if (!Uri.TryCreate(context.PostLogoutRedirectUri, UriKind.Absolute, out Uri uri) || if (!Uri.TryCreate(context.PostLogoutRedirectUri, UriKind.Absolute, out Uri uri) || !uri.IsWellFormedOriginalString())
!uri.IsWellFormedOriginalString())
{ {
context.Logger.LogError("The logout request was rejected because the specified post_logout_redirect_uri " + context.Logger.LogError("The logout request was rejected because the specified post_logout_redirect_uri " +
"was not a valid absolute URL: {PostLogoutRedirectUri}.", context.PostLogoutRedirectUri); "was not a valid absolute URL: {PostLogoutRedirectUri}.", context.PostLogoutRedirectUri);
@ -383,7 +382,7 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'post_logout_redirect_uri' parameter must be a valid absolute URL."); description: "The 'post_logout_redirect_uri' parameter must be a valid absolute URL.");
return Task.CompletedTask; return default;
} }
if (!string.IsNullOrEmpty(uri.Fragment)) if (!string.IsNullOrEmpty(uri.Fragment))
@ -395,10 +394,10 @@ namespace OpenIddict.Server
error: Errors.InvalidRequest, error: Errors.InvalidRequest,
description: "The 'post_logout_redirect_uri' parameter must not include a fragment."); description: "The 'post_logout_redirect_uri' parameter must not include a fragment.");
return Task.CompletedTask; return default;
} }
return Task.CompletedTask; return default;
} }
} }
@ -437,9 +436,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ValidateLogoutRequestContext context) public async ValueTask HandleAsync([NotNull] ValidateLogoutRequestContext context)
{ {
if (context == null) if (context == null)
{ {
@ -458,7 +457,7 @@ namespace OpenIddict.Server
return; return;
} }
async Task<bool> ValidatePostLogoutRedirectUriAsync(string address) async ValueTask<bool> ValidatePostLogoutRedirectUriAsync(string address)
{ {
// To be considered valid, a post_logout_redirect_uri must correspond to an existing client application // To be considered valid, a post_logout_redirect_uri must correspond to an existing client application
// that was granted the ept:logout permission, unless endpoint permissions checking was explicitly disabled. // that was granted the ept:logout permission, unless endpoint permissions checking was explicitly disabled.
@ -507,9 +506,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -518,7 +517,7 @@ namespace OpenIddict.Server
if (context.Request == null) if (context.Request == null)
{ {
return Task.CompletedTask; return default;
} }
// Note: at this stage, the validated redirect URI property may be null (e.g if an error // Note: at this stage, the validated redirect URI property may be null (e.g if an error
@ -528,7 +527,7 @@ namespace OpenIddict.Server
context.PostLogoutRedirectUri = (string) property; context.PostLogoutRedirectUri = (string) property;
} }
return Task.CompletedTask; return default;
} }
} }
@ -551,9 +550,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ApplyLogoutResponseContext context) public ValueTask HandleAsync([NotNull] ApplyLogoutResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -566,7 +565,7 @@ namespace OpenIddict.Server
context.Response.State = context.Request?.State; context.Response.State = context.Request?.State;
} }
return Task.CompletedTask; return default;
} }
} }
} }

46
src/OpenIddict.Server/OpenIddictServerHandlers.cs

@ -67,9 +67,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessChallengeResponseContext context) public ValueTask HandleAsync([NotNull] ProcessChallengeResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -98,7 +98,7 @@ namespace OpenIddict.Server
}; };
} }
return Task.CompletedTask; return default;
} }
} }
@ -122,9 +122,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessSigninResponseContext context) public ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -156,7 +156,7 @@ namespace OpenIddict.Server
.ToString()); .ToString());
} }
return Task.CompletedTask; return default;
} }
} }
@ -179,9 +179,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessSigninResponseContext context) public ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -196,7 +196,7 @@ namespace OpenIddict.Server
context.Principal.SetScopes(Scopes.OpenId); context.Principal.SetScopes(Scopes.OpenId);
} }
return Task.CompletedTask; return default;
} }
} }
@ -219,9 +219,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessSigninResponseContext context) public ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -235,7 +235,7 @@ namespace OpenIddict.Server
context.Principal.SetPresenters(context.ClientId); context.Principal.SetPresenters(context.ClientId);
} }
return Task.CompletedTask; return default;
} }
} }
@ -258,9 +258,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public Task HandleAsync([NotNull] ProcessSigninResponseContext context) public ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -321,7 +321,7 @@ namespace OpenIddict.Server
_ => false _ => false
}; };
return Task.CompletedTask; return default;
} }
} }
@ -350,9 +350,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessSigninResponseContext context) public async ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -476,9 +476,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessSigninResponseContext context) public async ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -566,9 +566,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessSigninResponseContext context) public async ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {
@ -630,9 +630,9 @@ namespace OpenIddict.Server
/// </summary> /// </summary>
/// <param name="context">The context associated with the event to process.</param> /// <param name="context">The context associated with the event to process.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public async Task HandleAsync([NotNull] ProcessSigninResponseContext context) public async ValueTask HandleAsync([NotNull] ProcessSigninResponseContext context)
{ {
if (context == null) if (context == null)
{ {

4
src/OpenIddict.Server/OpenIddictServerProvider.cs

@ -42,7 +42,7 @@ namespace OpenIddict.Server
Options = _options.CurrentValue Options = _options.CurrentValue
}); });
public async Task DispatchAsync<TContext>([NotNull] TContext context) where TContext : BaseContext public async ValueTask DispatchAsync<TContext>([NotNull] TContext context) where TContext : BaseContext
{ {
if (context == null) if (context == null)
{ {
@ -116,7 +116,7 @@ namespace OpenIddict.Server
} }
} }
async Task<bool> IsActiveAsync(OpenIddictServerHandlerDescriptor descriptor) async ValueTask<bool> IsActiveAsync(OpenIddictServerHandlerDescriptor descriptor)
{ {
for (var index = 0; index < descriptor.FilterTypes.Length; index++) for (var index = 0; index < descriptor.FilterTypes.Length; index++)
{ {

Loading…
Cancel
Save