Adding support for .NET 8.0 LTS, renaming private fields to start with underscore
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user