1
0

Adding support for .NET 8.0 LTS, renaming private fields to start with underscore

This commit is contained in:
2023-12-29 01:58:40 +01:00
parent 8bd511a936
commit 99d3f7758a
59 changed files with 922 additions and 871 deletions

View File

@@ -13,8 +13,8 @@ namespace AMWD.Common.AspNetCore.Security.BasicAuthentication
/// </summary>
public class BasicAuthenticationMiddleware
{
private readonly RequestDelegate next;
private readonly IBasicAuthenticationValidator validator;
private readonly RequestDelegate _next;
private readonly IBasicAuthenticationValidator _validator;
/// <summary>
/// Initializes a new instance of the <see cref="BasicAuthenticationMiddleware"/> class.
@@ -23,8 +23,8 @@ namespace AMWD.Common.AspNetCore.Security.BasicAuthentication
/// <param name="validator">A basic authentication validator.</param>
public BasicAuthenticationMiddleware(RequestDelegate next, IBasicAuthenticationValidator validator)
{
this.next = next;
this.validator = validator;
_next = next;
_validator = validator;
}
/// <summary>
@@ -37,7 +37,7 @@ namespace AMWD.Common.AspNetCore.Security.BasicAuthentication
{
if (!httpContext.Request.Headers.ContainsKey("Authorization"))
{
SetAuthenticateRequest(httpContext, validator.Realm);
SetAuthenticateRequest(httpContext, _validator.Realm);
return;
}
@@ -51,14 +51,14 @@ namespace AMWD.Common.AspNetCore.Security.BasicAuthentication
string username = plain.Split(':').First();
string password = plain[(username.Length + 1)..];
var principal = await validator.ValidateAsync(username, password, httpContext.GetRemoteIpAddress(), httpContext.RequestAborted).ConfigureAwait(false);
var principal = await _validator.ValidateAsync(username, password, httpContext.GetRemoteIpAddress(), httpContext.RequestAborted).ConfigureAwait(false);
if (principal == null)
{
SetAuthenticateRequest(httpContext, validator.Realm);
SetAuthenticateRequest(httpContext, _validator.Realm);
return;
}
await next.Invoke(httpContext).ConfigureAwait(false);
await _next.Invoke(httpContext).ConfigureAwait(false);
}
catch (Exception ex)
{