|
|
|
@ -18,6 +18,27 @@ namespace OpenIddict.Server.Owin |
|
|
|
/// </summary>
|
|
|
|
public static class OpenIddictServerOwinHandlerFilters |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Represents a filter that excludes the associated handlers if authorization endpoint caching was not enabled.
|
|
|
|
/// </summary>
|
|
|
|
public class RequireAuthorizationEndpointCachingEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
{ |
|
|
|
private readonly IOptionsMonitor<OpenIddictServerOwinOptions> _options; |
|
|
|
|
|
|
|
public RequireAuthorizationEndpointCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
=> _options = options; |
|
|
|
|
|
|
|
public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context) |
|
|
|
{ |
|
|
|
if (context == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<bool>(_options.CurrentValue.EnableAuthorizationEndpointCaching); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a filter that excludes the associated handlers if the
|
|
|
|
/// pass-through mode was not enabled for the authorization endpoint.
|
|
|
|
@ -62,14 +83,13 @@ namespace OpenIddict.Server.Owin |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a filter that excludes the associated handlers if the
|
|
|
|
/// pass-through mode was not enabled for the logout endpoint.
|
|
|
|
/// Represents a filter that excludes the associated handlers if logout endpoint caching was not enabled.
|
|
|
|
/// </summary>
|
|
|
|
public class RequireLogoutEndpointPassthroughEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
public class RequireLogoutEndpointCachingEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
{ |
|
|
|
private readonly IOptionsMonitor<OpenIddictServerOwinOptions> _options; |
|
|
|
|
|
|
|
public RequireLogoutEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
public RequireLogoutEndpointCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
=> _options = options; |
|
|
|
|
|
|
|
public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context) |
|
|
|
@ -79,15 +99,21 @@ namespace OpenIddict.Server.Owin |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<bool>(_options.CurrentValue.EnableLogoutEndpointPassthrough); |
|
|
|
return new ValueTask<bool>(_options.CurrentValue.EnableLogoutEndpointCaching); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a filter that excludes the associated handlers if no OWIN request can be found.
|
|
|
|
/// Represents a filter that excludes the associated handlers if the
|
|
|
|
/// pass-through mode was not enabled for the logout endpoint.
|
|
|
|
/// </summary>
|
|
|
|
public class RequireOwinRequest : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
public class RequireLogoutEndpointPassthroughEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
{ |
|
|
|
private readonly IOptionsMonitor<OpenIddictServerOwinOptions> _options; |
|
|
|
|
|
|
|
public RequireLogoutEndpointPassthroughEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
=> _options = options; |
|
|
|
|
|
|
|
public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context) |
|
|
|
{ |
|
|
|
if (context == null) |
|
|
|
@ -95,20 +121,15 @@ namespace OpenIddict.Server.Owin |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<bool>(context.Transaction.GetOwinRequest() != null); |
|
|
|
return new ValueTask<bool>(_options.CurrentValue.EnableLogoutEndpointPassthrough); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a filter that excludes the associated handlers if the HTTPS requirement was disabled.
|
|
|
|
/// Represents a filter that excludes the associated handlers if no OWIN request can be found.
|
|
|
|
/// </summary>
|
|
|
|
public class RequireTransportSecurityRequirementEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
public class RequireOwinRequest : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
{ |
|
|
|
private readonly IOptionsMonitor<OpenIddictServerOwinOptions> _options; |
|
|
|
|
|
|
|
public RequireTransportSecurityRequirementEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
=> _options = options; |
|
|
|
|
|
|
|
public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context) |
|
|
|
{ |
|
|
|
if (context == null) |
|
|
|
@ -116,18 +137,18 @@ namespace OpenIddict.Server.Owin |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<bool>(!_options.CurrentValue.DisableTransportSecurityRequirement); |
|
|
|
return new ValueTask<bool>(context.Transaction.GetOwinRequest() != null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a filter that excludes the associated handlers if request caching was not enabled.
|
|
|
|
/// Represents a filter that excludes the associated handlers if the HTTPS requirement was disabled.
|
|
|
|
/// </summary>
|
|
|
|
public class RequireRequestCachingEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
public class RequireTransportSecurityRequirementEnabled : IOpenIddictServerHandlerFilter<BaseContext> |
|
|
|
{ |
|
|
|
private readonly IOptionsMonitor<OpenIddictServerOwinOptions> _options; |
|
|
|
|
|
|
|
public RequireRequestCachingEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
public RequireTransportSecurityRequirementEnabled([NotNull] IOptionsMonitor<OpenIddictServerOwinOptions> options) |
|
|
|
=> _options = options; |
|
|
|
|
|
|
|
public ValueTask<bool> IsActiveAsync([NotNull] BaseContext context) |
|
|
|
@ -137,7 +158,7 @@ namespace OpenIddict.Server.Owin |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<bool>(_options.CurrentValue.EnableRequestCaching); |
|
|
|
return new ValueTask<bool>(!_options.CurrentValue.DisableTransportSecurityRequirement); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|