first commit

This commit is contained in:
2025-02-26 23:42:19 +01:00
commit 777ea98be1
283 changed files with 88266 additions and 0 deletions
@@ -0,0 +1,8 @@
using System.Net;
namespace OpenWarehouse.auth.api.Common.CustomIdentifyManager;
public enum AccountClaims
{
ServiceAdress, IfUserCanChangeRole, ServiceName,
}
@@ -0,0 +1,42 @@
using System.Diagnostics;
namespace OpenWarehouse.auth.api.Common.CustomIdentifyManager;
public static class AccountClaimsClass
{
private static readonly Dictionary<AccountClaims, string> AccountTypeDict = new()
{
{ AccountClaims.ServiceAdress, "Service_Adress" },
{ AccountClaims.ServiceName, "ServiceName" },
{ AccountClaims.IfUserCanChangeRole, "PrivilageFunct" }
};
public static Claim GetClaim(this AccountClaims claims, string val)
{
var isSuccess = AccountTypeDict.TryGetValue(claims,out var res);
if (isSuccess && res != null)
{
return new Claim(res, val);
}
else
{
throw new NotImplementedException("Claim not implemented!");
}
}
public static string GetName(AccountClaims claims)
{
var isSuccess = AccountTypeDict.TryGetValue(claims,out var res);
if (isSuccess && res != null)
{
return res;
}
else
{
throw new NotImplementedException("Claim not implemented!");
}
}
}
@@ -0,0 +1,6 @@
namespace OpenWarehouse.auth.api.Common.CustomIdentifyManager;
public enum AccountType
{
User, Admin, Service, Uknow
}
@@ -0,0 +1,31 @@
namespace OpenWarehouse.auth.api.Common.CustomIdentifyManager;
public static class AccountTypeFunction
{
public static string AccountTypeType { get; } = "AccountType";
private static readonly Dictionary<AccountType, string> AccountTypeMap = new()
{
{ AccountType.User, "User" },
{ AccountType.Admin, "Admin" },
{ AccountType.Service, "Service" },
{ AccountType.Uknow, "Uknow" },
};
public static string GetValue(this AccountType accountType)
{
var isSuccess = AccountTypeMap.TryGetValue(accountType, out var acountString);
if (isSuccess && acountString != null)
{
return acountString;
}
throw new Exception("Account type not in AccountTypeMap.");
}
public static Claim Claim(this AccountType accountType)
{
return new Claim(AccountTypeType, accountType.GetValue());
}
}