Adds Argon2 for password protection (#123)

This commit is contained in:
Kamron Batman 2020-05-01 22:42:39 -07:00 committed by GitHub
parent 29467a3ed9
commit dad8a64fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 1152 additions and 167 deletions

View file

@ -0,0 +1,30 @@
using Server.Accounting.Security;
using Xunit;
namespace Server.Tests.Accounting.Security
{
public class Argon2PasswordProtectionTest
{
private const string plainPassword = "hello-good-sir";
[Fact]
public void TestValidates()
{
var passwordProtection = new Argon2PasswordProtection();
string encryptedPassword = passwordProtection.EncryptPassword(plainPassword);
Assert.True(passwordProtection.ValidatePassword(encryptedPassword, plainPassword));
}
[Fact]
public void TestPasswordDoesNotValidate()
{
var passwordProtection = new Argon2PasswordProtection();
string encryptedPassword = passwordProtection.EncryptPassword(plainPassword);
Assert.False(passwordProtection.ValidatePassword(encryptedPassword, "Not the same password"));
}
}
}

View file

@ -1,7 +1,7 @@
using Server.Accounting.Security;
using Xunit;
using Server.Accounting;
namespace Server.Tests.Accounting
namespace Server.Tests.Accounting.Security
{
public class PBKDF2PasswordProtectionTest
{

View file

@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
<DefineConstants Condition="'$(RuntimeIdentifier)' == 'win-x64'">WINDOWS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />