mirror of
https://github.com/alex289/CleanArchitecture.git
synced 2025-06-30 18:42:56 +00:00
28 lines
928 B
C#
28 lines
928 B
C#
using System.Security.Claims;
|
|
using System.Text.Encodings.Web;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace CleanArchitecture.IntegrationTests.Infrastructure.Auth;
|
|
|
|
public sealed class TestAuthenticationHandler : AuthenticationHandler<TestAuthenticationOptions>
|
|
{
|
|
public TestAuthenticationHandler(
|
|
IOptionsMonitor<TestAuthenticationOptions> options,
|
|
ILoggerFactory logger,
|
|
UrlEncoder encoder) : base(options, logger, encoder)
|
|
{
|
|
}
|
|
|
|
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
|
{
|
|
var authenticationTicket = new AuthenticationTicket(
|
|
new ClaimsPrincipal(Options.Identity),
|
|
new AuthenticationProperties(),
|
|
"Testing");
|
|
|
|
return Task.FromResult(AuthenticateResult.Success(authenticationTicket));
|
|
}
|
|
} |