using Microsoft.Extensions.Options; using ProtoBuf.Grpc; using EonaCat.gRPC.Api.Helpers; using EonaCat.gRPC.Proto; namespace EonaCat.gRPC.Api.Services; public class AuthenticationHandler : IAuthenticationService { private readonly IOptions _appSettings; public AuthenticationHandler(IOptions appSettings) { _appSettings = appSettings; } public Task Authenticate(AuthenticationRequest request, CallContext context = default) { var authenticationResponse = JwtAuthenticationManager.Authenticate(_appSettings, request); if (authenticationResponse == null) throw new RpcException(new Status(StatusCode.Unauthenticated, "Invalid ProtoUserResponse Credentials")); return Task.FromResult(authenticationResponse); } }