add authorization

This commit is contained in:
Alex Bezdieniezhnykh
2024-11-11 21:07:28 +02:00
parent ca6175da7f
commit 85139b4fd2
12 changed files with 146 additions and 40 deletions
+1
View File
@@ -8,6 +8,7 @@ public class BusinessException(ExceptionEnum exEnum, string message) : Exception
public enum ExceptionEnum
{
NoUserFound = 10,
NoUser = 15,
UserExists = 20,
PasswordIncorrect = 30,
UserLengthIncorrect = 33,
+6
View File
@@ -0,0 +1,6 @@
namespace Azaion.Common.Configs;
public class Constants
{
public const string HARDWARE_ID = nameof(HARDWARE_ID);
}
+8
View File
@@ -0,0 +1,8 @@
namespace Azaion.Common.Configs;
public class JwtConfig
{
public string Issuer { get; set; } = null!;
public string Audience { get; set; } = null!;
public string Secret { get; set; }
}
+3 -2
View File
@@ -1,9 +1,10 @@
namespace Azaion.Common;
namespace Azaion.Common.Entities;
public enum RoleEnum
{
Operator,
Validator,
CompanionPC,
Admin
Admin,
ApiAdmin
}
+1 -3
View File
@@ -3,10 +3,8 @@
public class User
{
public string Id { get; set; } = null!;
public string Username { get; set; } = null!;
public string Email { get; set; } = null!;
public string PasswordHash { get; set; } = null!;
public string HardwareId { get; set; } = null!;
public RoleEnum Role { get; set; }
public string UniqueKey => $"Azaion#{Username}#{PasswordHash}#{HardwareId}";
}
+2 -3
View File
@@ -4,9 +4,8 @@ namespace Azaion.Common.Requests;
public class GetResourceRequest
{
public string Username { get; set; } = null!;
public string Password { get; set; } = null!;
public string HardwareId { get; set; } = null!;
public string Password { get; set; } = null!;
public string HardwareId { get; set; } = null!;
public ResourceEnum ResourceEnum { get; set; }
}
@@ -1,3 +1,4 @@
using Azaion.Common.Entities;
using FluentValidation;
namespace Azaion.Common.Requests;