mirror of
https://github.com/ditkrg/asp.netcore-authentication.git
synced 2026-01-24 06:57:06 +00:00
Compare commits
No commits in common. "main" and "0.2.0" have entirely different histories.
@ -1,14 +1,7 @@
|
|||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
|
|
||||||
namespace DIT.Authentication.GatewayAuth.Abstractions;
|
namespace DIT.Authentication.GatewayAuth.Abstractions;
|
||||||
|
|
||||||
public interface IForbidResponseHandler
|
|
||||||
{
|
|
||||||
Task HandleForbiddenAsync(HttpContext context, AuthenticationProperties properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ISignatureValidator
|
public interface ISignatureValidator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ using System.Security.Claims;
|
|||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using DIT.Authentication.GatewayAuth.Abstractions;
|
using DIT.Authentication.GatewayAuth.Abstractions;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
@ -15,11 +14,9 @@ public class GatewayAuthHandler : AuthenticationHandler<GatewayAuthOptions>
|
|||||||
|
|
||||||
private readonly IClaimsProvider _claimsProvider;
|
private readonly IClaimsProvider _claimsProvider;
|
||||||
private readonly ISignatureValidator _signatureValidator;
|
private readonly ISignatureValidator _signatureValidator;
|
||||||
private readonly IForbidResponseHandler? _forbidResponseHandler;
|
|
||||||
|
|
||||||
public GatewayAuthHandler(
|
public GatewayAuthHandler(
|
||||||
IClaimsProvider claimsProvider,
|
IClaimsProvider claimsProvider,
|
||||||
IServiceProvider serviceProvider,
|
|
||||||
UrlEncoder encoder,
|
UrlEncoder encoder,
|
||||||
IOptionsMonitor<GatewayAuthOptions> options,
|
IOptionsMonitor<GatewayAuthOptions> options,
|
||||||
ILoggerFactory logger,
|
ILoggerFactory logger,
|
||||||
@ -28,8 +25,6 @@ public class GatewayAuthHandler : AuthenticationHandler<GatewayAuthOptions>
|
|||||||
{
|
{
|
||||||
_claimsProvider = claimsProvider;
|
_claimsProvider = claimsProvider;
|
||||||
_signatureValidator = signatureValidator;
|
_signatureValidator = signatureValidator;
|
||||||
|
|
||||||
_forbidResponseHandler = serviceProvider.GetService<IForbidResponseHandler>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||||
@ -64,14 +59,6 @@ public class GatewayAuthHandler : AuthenticationHandler<GatewayAuthOptions>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task HandleForbiddenAsync(AuthenticationProperties properties)
|
|
||||||
{
|
|
||||||
if (_forbidResponseHandler != null)
|
|
||||||
return _forbidResponseHandler.HandleForbiddenAsync(Context, properties);
|
|
||||||
|
|
||||||
return base.HandleForbiddenAsync(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool ExtractSignatureValue(string signatureHeader, [NotNullWhen(true)] out string? signature)
|
private static bool ExtractSignatureValue(string signatureHeader, [NotNullWhen(true)] out string? signature)
|
||||||
{
|
{
|
||||||
const string signaturePrefix = "signature=";
|
const string signaturePrefix = "signature=";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user