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:
rootdarkarchon 2022-10-13 16:55:23 +02:00 committed by GitHub
parent d37c1208fe
commit c98e2b2dd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 313 additions and 159 deletions

View file

@ -14,7 +14,7 @@ using Microsoft.Extensions.Logging;
namespace MareSynchronosServices.Authentication;
public class SecretKeyAuthenticationHandler
internal class SecretKeyAuthenticationHandler
{
private readonly ILogger<SecretKeyAuthenticationHandler> logger;
private readonly MareMetrics metrics;
@ -60,7 +60,7 @@ public class SecretKeyAuthenticationHandler
if (string.IsNullOrEmpty(secretKey))
{
metrics.IncCounter(MetricsAPI.CounterAuthenticationFailures);
return new AuthReply() { Success = false, Uid = string.Empty };
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
}
lock (failedAuthLock)
@ -86,7 +86,7 @@ public class SecretKeyAuthenticationHandler
}, token);
logger.LogWarning("TempBan {ip} for authorization spam", ip);
return new AuthReply() { Success = false, Uid = string.Empty };
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
}
}
@ -115,7 +115,7 @@ public class SecretKeyAuthenticationHandler
}
}
return new AuthReply() { Success = false, Uid = string.Empty };
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
}
metrics.IncCounter(MetricsAPI.CounterAuthenticationCacheHits);
@ -152,7 +152,7 @@ public class SecretKeyAuthenticationHandler
}
metrics.IncCounter(MetricsAPI.CounterAuthenticationFailures);
return new AuthReply() { Success = false, Uid = string.Empty };
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
}
lock (authDictLock)
@ -163,7 +163,7 @@ public class SecretKeyAuthenticationHandler
metrics.IncCounter(MetricsAPI.CounterAuthenticationSuccesses);
return new AuthReply() { Success = true, Uid = uid };
return new AuthReply() { Success = true, Uid = new UidMessage() { Uid = uid } };
}
public SecretKeyAuthenticationHandler(IConfiguration configuration, ILogger<SecretKeyAuthenticationHandler> logger, MareMetrics metrics)