Add AuthLifetimeService
Refactor AuthManager
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Akari.Prototype.Server.Utils
|
||||
{
|
||||
public static class AkariPath
|
||||
{
|
||||
public const string BasePath = "Data";
|
||||
|
||||
public static string GetPath(string path) => Path.Combine(BasePath, path);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using Isopoh.Cryptography.Argon2;
|
||||
using Isopoh.Cryptography.SecureArray;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Akari.Prototype.Server.Utils
|
||||
@@ -31,5 +33,34 @@ namespace Akari.Prototype.Server.Utils
|
||||
|
||||
return Argon2.Hash(config);
|
||||
}
|
||||
|
||||
public static SecureArray<byte> Argon2idDeriveBytes(byte[] password, byte[] salt, int length, bool clear = false, int? threads = null)
|
||||
{
|
||||
int t = threads ?? Environment.ProcessorCount / 2;
|
||||
|
||||
if (t < 1)
|
||||
{
|
||||
t = 1;
|
||||
}
|
||||
|
||||
var config = new Argon2Config()
|
||||
{
|
||||
HashLength = length,
|
||||
Password = password,
|
||||
Salt = salt,
|
||||
Lanes = t,
|
||||
Threads = t,
|
||||
ClearPassword = clear,
|
||||
ClearSecret = clear,
|
||||
Type = Argon2Type.HybridAddressing,
|
||||
Version = Argon2Version.Nineteen
|
||||
};
|
||||
|
||||
return new Argon2(config).Hash();
|
||||
}
|
||||
public static SecureArray<byte> Argon2idDeriveBytes(string password, string salt, int length, bool clear = false, int? threads = null)
|
||||
{
|
||||
return Argon2idDeriveBytes(Encoding.UTF8.GetBytes(password), Encoding.UTF8.GetBytes(salt), length, clear, threads);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user