Fixes configurations. (#128)

This commit is contained in:
Kamron Batman 2020-05-03 12:03:24 -07:00 committed by GitHub
parent f336a56364
commit cf8620d558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 25 additions and 21 deletions

View file

@ -40,14 +40,17 @@ namespace Server.Accounting.Security
public static class AccountSecurity
{
// TODO: Put it in a configuration
public const PasswordProtectionAlgorithm AlgorithmName = PasswordProtectionAlgorithm.Argon2;
public static PasswordProtectionAlgorithm CurrentAlgorithm { get; set; }
public static readonly IPasswordProtection CurrentPasswordProtection = GetPasswordProtection(AlgorithmName);
public static readonly IPasswordProtection CurrentPasswordProtection = GetPasswordProtection(CurrentAlgorithm);
public static void Configure()
{
if (AlgorithmName < PasswordProtectionAlgorithm.SHA2)
throw new Exception($"Security: {AlgorithmName} is obselete and not secure. Do not use it.");
CurrentAlgorithm =
ServerConfiguration.GetOrUpdateSetting("accountSecurity.encryptionAlgorithm", PasswordProtectionAlgorithm.Argon2);
if (CurrentAlgorithm < PasswordProtectionAlgorithm.SHA2)
throw new Exception($"Security: {CurrentAlgorithm} is obselete and not secure. Do not use it.");
}
public static IPasswordProtection GetPasswordProtection(PasswordProtectionAlgorithm algorithm)