Updated to C# 12
This commit is contained in:
@@ -13,49 +13,39 @@ using Microsoft.Extensions.Options;
|
||||
|
||||
namespace AMWD.Common.AspNetCore.Security.BasicAuthentication
|
||||
{
|
||||
#if NET8_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Implements the <see cref="AuthenticationHandler{TOptions}"/> for Basic Authentication.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="BasicAuthenticationHandler"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="options" > The monitor for the options instance.</param>
|
||||
/// <param name="logger">The <see cref="ILoggerFactory"/>.</param>
|
||||
/// <param name="encoder">The <see cref="UrlEncoder"/>.</param>
|
||||
/// <param name="validator">An basic autentication validator implementation.</param>
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public class BasicAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
public class BasicAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, IBasicAuthenticationValidator validator)
|
||||
: AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder)
|
||||
#else
|
||||
/// <summary>
|
||||
/// Implements the <see cref="AuthenticationHandler{TOptions}"/> for Basic Authentication.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="BasicAuthenticationHandler"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="options" > The monitor for the options instance.</param>
|
||||
/// <param name="logger">The <see cref="ILoggerFactory"/>.</param>
|
||||
/// <param name="encoder">The <see cref="UrlEncoder"/>.</param>
|
||||
/// <param name="clock">The <see cref="ISystemClock"/>.</param>
|
||||
/// <param name="validator">An basic autentication validator implementation.</param>
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public class BasicAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IBasicAuthenticationValidator validator)
|
||||
: AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder, clock)
|
||||
#endif
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IBasicAuthenticationValidator _validator;
|
||||
|
||||
#if NET8_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BasicAuthenticationHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">The monitor for the options instance.</param>
|
||||
/// <param name="logger">The <see cref="ILoggerFactory"/>.</param>
|
||||
/// <param name="encoder">The <see cref="UrlEncoder"/>.</param>
|
||||
/// <param name="validator">An basic autentication validator implementation.</param>
|
||||
public BasicAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, IBasicAuthenticationValidator validator)
|
||||
: base(options, logger, encoder)
|
||||
{
|
||||
_logger = logger.CreateLogger<BasicAuthenticationHandler>();
|
||||
_validator = validator;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NET6_0
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BasicAuthenticationHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options" > The monitor for the options instance.</param>
|
||||
/// <param name="logger">The <see cref="ILoggerFactory"/>.</param>
|
||||
/// <param name="encoder">The <see cref="UrlEncoder"/>.</param>
|
||||
/// <param name="clock">The <see cref="ISystemClock"/>.</param>
|
||||
/// <param name="validator">An basic autentication validator implementation.</param>
|
||||
public BasicAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IBasicAuthenticationValidator validator)
|
||||
: base(options, logger, encoder, clock)
|
||||
{
|
||||
_logger = logger.CreateLogger<BasicAuthenticationHandler>();
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
#endif
|
||||
private readonly ILogger _logger = logger.CreateLogger<BasicAuthenticationHandler>();
|
||||
private readonly IBasicAuthenticationValidator _validator = validator;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
|
||||
Reference in New Issue
Block a user