mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 23:06:31 +00:00
refactor external clients
put model batch size as parameter in config
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Azaion.CommonSecurity.DTO.Commands;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Azaion.CommonSecurity.Services;
|
||||
|
||||
public interface IAuthProvider
|
||||
{
|
||||
void Login(ApiCredentials credentials);
|
||||
User CurrentUser { get; }
|
||||
}
|
||||
|
||||
public class AuthProvider([FromKeyedServices(SecurityConstants.EXTERNAL_INFERENCE_PATH)] IExternalClient externalClient) : IAuthProvider
|
||||
{
|
||||
public User CurrentUser { get; private set; } = null!;
|
||||
|
||||
public void Login(ApiCredentials credentials)
|
||||
{
|
||||
externalClient.Send(RemoteCommand.Create(CommandType.Login, credentials));
|
||||
var user = externalClient.Get<User>();
|
||||
if (user == null)
|
||||
throw new Exception("Can't get user from Auth provider");
|
||||
|
||||
CurrentUser = user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user