queue + local sqlite WIP

This commit is contained in:
Alex Bezdieniezhnykh
2024-12-17 18:46:33 +02:00
parent 626767469a
commit 5fa18aa514
47 changed files with 694 additions and 222 deletions
+8
View File
@@ -0,0 +1,8 @@
namespace Azaion.CommonSecurity.DTO;
public class ApiConfig
{
public string Url { get; set; } = null!;
public int RetryCount {get;set;}
public double TimeoutSeconds { get; set; }
}
@@ -0,0 +1,7 @@
namespace Azaion.CommonSecurity.DTO;
public class ApiCredentials(string email, string password) : EventArgs
{
public string Email { get; set; } = email;
public string Password { get; set; } = password;
}
+11
View File
@@ -0,0 +1,11 @@
namespace Azaion.CommonSecurity.DTO;
public class HardwareInfo
{
public string CPU { get; set; } = null!;
public string GPU { get; set; } = null!;
public string MacAddress { get; set; } = null!;
public string Memory { get; set; } = null!;
public string Hash { get; set; } = null!;
}
@@ -0,0 +1,6 @@
namespace Azaion.CommonSecurity.DTO;
public class LoginResponse
{
public string Token { get; set; } = null!;
}
+12
View File
@@ -0,0 +1,12 @@
namespace Azaion.CommonSecurity.DTO;
public enum RoleEnum
{
None = 0,
Operator = 10, //only annotator is available. Could send annotations to queue.
Validator = 20, //annotator + dataset explorer. This role allows to receive annotations from the queue.
CompanionPC = 30,
Admin = 40, //
ResourceUploader = 50, //Uploading dll and ai models
ApiAdmin = 1000 //everything
}
@@ -0,0 +1,6 @@
namespace Azaion.CommonSecurity.DTO;
public class SecureAppConfig
{
public ApiConfig ApiConfig { get; set; } = null!;
}
+21
View File
@@ -0,0 +1,21 @@
using System.Security.Claims;
namespace Azaion.CommonSecurity.DTO;
public class User
{
public Guid Id { get; set; }
public string Email { get; set; }
public RoleEnum Role { get; set; }
public User(IEnumerable<Claim> claims)
{
var claimDict = claims.ToDictionary(x => x.Type, x => x.Value);
Id = Guid.Parse(claimDict[SecurityConstants.CLAIM_NAME_ID]);
Email = claimDict[SecurityConstants.CLAIM_EMAIL];
if (!Enum.TryParse(claimDict[SecurityConstants.CLAIM_ROLE], out RoleEnum role))
role = RoleEnum.None;
Role = role;
}
}