You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Security/Authentication/AuthenticationService.cs

28 lines
828 B

2 years ago
using Connected.Middleware;
using Connected.Security.Authentication.Middleware;
using Connected.Threading;
namespace Connected.Security.Authentication;
/// <summary>
/// The implementation of the <see cref="IAuthenticationService"/>.
/// </summary>
internal sealed class AuthenticationService : IAuthenticationService
{
public AuthenticationService(IMiddlewareService middleware)
{
Provider = new AsyncLazy<IAuthenticationMiddleware>(middleware.First<IAuthenticationMiddleware>());
}
private AsyncLazy<IAuthenticationMiddleware> Provider { get; }
public async Task<IAuthenticationResult> Authenticate(AuthenticationArgs args)
{
var provider = await Provider.Value;
if (provider is null)
throw new NullReferenceException(nameof(IAuthenticationMiddleware));
return await provider.Authenticate(args);
}
}