Fix: Referencias al Auth

This commit is contained in:
Luis Martinez 2023-02-02 11:21:46 -05:00
parent e9a8bf6069
commit 125ef8b3ea
4 changed files with 18 additions and 2 deletions

View File

@ -11,6 +11,7 @@ namespace Security
public static string? HashKey { get; private set; }
private static string? PwdKey { get; set; }
// private static readonly HttpClient client = new();
public Encripter()
{
string? mode = Environment.GetEnvironmentVariable("Mode");
@ -164,6 +165,19 @@ namespace Security
return Base64Encode(encryptedText);
}
public static string Descypher(string value)
{
string b64Decrypted = Base64Decode(value);
string decryptedText = "";
for (int i = 0; i < b64Decrypted.Length; i++)
{
int encrypted = (int)b64Decrypted[i];
int decryption = encrypted - _SEMILLA;
decryptedText += Char.ConvertFromUtf32(decryption);
}
return decryptedText;
}
public static string Base64Decode(string base64EncodedData)
{

View File

@ -12,7 +12,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Auth\Auth.csproj" />
<ProjectReference Include="..\..\Auth\Auth.csproj" />
</ItemGroup>
</Project>

View File

@ -83,6 +83,8 @@ namespace MSAdminUsuarios.Controllers
{
try
{
#warning este metodo se debe revisar, des-encriptado no se debe permitir!
JwtSecurityTokenHandler handler = new();
JwtSecurityToken tkn = handler.ReadJwtToken(Encripter.Descypher(token));
int pk = Int32.Parse(tkn.Claims.FirstOrDefault(c => c.Type == "pk").Value);

View File

@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Auth\Auth.csproj" />
<ProjectReference Include="..\..\Auth\Auth.csproj" />
</ItemGroup>
</Project>