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

@@ -10,9 +10,9 @@ namespace AMWD.Common.AspNetCore.Security.PathProtection
/// </summary>
public class ProtectedPathMiddleware
{
private readonly RequestDelegate next;
private readonly PathString path;
private readonly string policyName;
private readonly RequestDelegate _next;
private readonly PathString _path;
private readonly string _policyName;
/// <summary>
/// Initializes a new instance of the <see cref="ProtectedPathExtensions"/> class.
@@ -21,9 +21,9 @@ namespace AMWD.Common.AspNetCore.Security.PathProtection
/// <param name="options">The options to configure the middleware.</param>
public ProtectedPathMiddleware(RequestDelegate next, ProtectedPathOptions options)
{
this.next = next;
path = options.Path;
policyName = options.PolicyName;
_next = next;
_path = options.Path;
_policyName = options.PolicyName;
}
/// <summary>
@@ -35,16 +35,16 @@ namespace AMWD.Common.AspNetCore.Security.PathProtection
/// <returns>An awaitable task.</returns>
public async Task InvokeAsync(HttpContext httpContext, IAuthorizationService authorizationService)
{
if (httpContext.Request.Path.StartsWithSegments(path))
if (httpContext.Request.Path.StartsWithSegments(_path))
{
var result = await authorizationService.AuthorizeAsync(httpContext.User, null, policyName).ConfigureAwait(false);
var result = await authorizationService.AuthorizeAsync(httpContext.User, null, _policyName).ConfigureAwait(false);
if (!result.Succeeded)
{
await httpContext.ChallengeAsync().ConfigureAwait(false);
return;
}
}
await next.Invoke(httpContext).ConfigureAwait(false);
await _next.Invoke(httpContext).ConfigureAwait(false);
}
}
}