mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-30 19:33:39 +01:00
Switch Authentication to asynchronous streaming calls (#16)
* add base grpc service and swap auth service to streaming * remove Authorize from hub itself * remove unused usings * heave files server to net 7, add exception handling in grpc auth stream Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
parent
d37c1208fe
commit
c98e2b2dd6
20 changed files with 313 additions and 159 deletions
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MareSynchronosServices.Services;
|
||||
|
||||
public class AuthenticationService : AuthService.AuthServiceBase
|
||||
internal class AuthenticationService : AuthService.AuthServiceBase
|
||||
{
|
||||
private readonly ILogger<AuthenticationService> _logger;
|
||||
private readonly MareDbContext _dbContext;
|
||||
|
|
@ -20,12 +20,16 @@ public class AuthenticationService : AuthService.AuthServiceBase
|
|||
_authHandler = authHandler;
|
||||
}
|
||||
|
||||
public override async Task<AuthReply> Authorize(AuthRequest request, ServerCallContext context)
|
||||
public override async Task Authorize(IAsyncStreamReader<AuthRequest> requestStream, IServerStreamWriter<AuthReply> responseStream, ServerCallContext context)
|
||||
{
|
||||
return await _authHandler.AuthenticateAsync(_dbContext, request.Ip, request.SecretKey);
|
||||
await foreach (var input in requestStream.ReadAllAsync(context.CancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var response = await _authHandler.AuthenticateAsync(_dbContext, input.Ip, input.SecretKey).ConfigureAwait(false);
|
||||
await responseStream.WriteAsync(response, context.CancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
public override Task<Empty> RemoveAuth(RemoveAuthRequest request, ServerCallContext context)
|
||||
public override Task<Empty> RemoveAuth(UidMessage request, ServerCallContext context)
|
||||
{
|
||||
_logger.LogInformation("Removing Authentication for {uid}", request.Uid);
|
||||
_authHandler.RemoveAuthentication(request.Uid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue