Changement de l'algorithme de hashage de mot de passe pour correspondre à celui utilisé en PHP
continuous-integration/drone/push Build is passing Details

pull/47/head
Johnny RATTON 1 year ago
parent 9ceb4bed66
commit 0648340c09

@ -1,5 +1,6 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using DbContextLib; using DbContextLib;
using DevOne.Security.Cryptography.BCrypt;
using Entities; using Entities;
using Microsoft.AspNetCore.Cryptography.KeyDerivation; using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -20,12 +21,13 @@ public class StubbedContext : UserDbContext
{ {
Id = 1, Id = 1,
Username = "johnny", Username = "johnny",
Password = Convert.ToBase64String(KeyDerivation.Pbkdf2( /*Password = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: "Motdepasse", password: "Motdepasse",
salt: RandomNumberGenerator.GetBytes(128 / 8), salt: RandomNumberGenerator.GetBytes(128 / 8),
prf: KeyDerivationPrf.HMACSHA256, prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000, iterationCount: 100000,
numBytesRequested: 256 / 8)), numBytesRequested: 256 / 8)),*/
Password = BCryptHelper.HashPassword("Motdepasse", BCryptHelper.GenerateSalt()),
Email = "Johnny.RATTON@etu.uca.fr", Email = "Johnny.RATTON@etu.uca.fr",
IsAdmin = true IsAdmin = true
}, },
@ -33,12 +35,13 @@ public class StubbedContext : UserDbContext
{ {
Id = 2, Id = 2,
Username = "maxime", Username = "maxime",
Password = Convert.ToBase64String(KeyDerivation.Pbkdf2( /*Password = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: "Motdepasse", password: "Motdepasse",
salt: RandomNumberGenerator.GetBytes(128 / 8), salt: RandomNumberGenerator.GetBytes(128 / 8),
prf: KeyDerivationPrf.HMACSHA256, prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000, iterationCount: 100000,
numBytesRequested: 256 / 8)), numBytesRequested: 256 / 8)),*/
Password = BCryptHelper.HashPassword("Motdepasse", BCryptHelper.GenerateSalt()),
Email = "Maxime.SAPOUNTZIS@etu.uca.fr", Email = "Maxime.SAPOUNTZIS@etu.uca.fr",
IsAdmin = true IsAdmin = true
}, },
@ -46,12 +49,13 @@ public class StubbedContext : UserDbContext
{ {
Id = 3, Id = 3,
Username = "clement", Username = "clement",
Password = Convert.ToBase64String(KeyDerivation.Pbkdf2( /*Password = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: "Motdepasse", password: "Motdepasse",
salt: RandomNumberGenerator.GetBytes(128 / 8), salt: RandomNumberGenerator.GetBytes(128 / 8),
prf: KeyDerivationPrf.HMACSHA256, prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000, iterationCount: 100000,
numBytesRequested: 256 / 8)), numBytesRequested: 256 / 8)),*/
Password = BCryptHelper.HashPassword("Motdepasse", BCryptHelper.GenerateSalt()),
Email = "Clement.CHIEU@etu.uca.fr", Email = "Clement.CHIEU@etu.uca.fr",
IsAdmin = true IsAdmin = true
}, },
@ -59,12 +63,13 @@ public class StubbedContext : UserDbContext
{ {
Id = 4, Id = 4,
Username = "erwan", Username = "erwan",
Password = Convert.ToBase64String(KeyDerivation.Pbkdf2( /*Password = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: "Motdepasse", password: "Motdepasse",
salt: RandomNumberGenerator.GetBytes(128 / 8), salt: RandomNumberGenerator.GetBytes(128 / 8),
prf: KeyDerivationPrf.HMACSHA256, prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000, iterationCount: 100000,
numBytesRequested: 256 / 8)), numBytesRequested: 256 / 8)),*/
Password = BCryptHelper.HashPassword("Motdepasse", BCryptHelper.GenerateSalt()),
Email = "Erwan.MENAGER@etu.uca.fr", Email = "Erwan.MENAGER@etu.uca.fr",
IsAdmin = true IsAdmin = true
}, },
@ -72,12 +77,13 @@ public class StubbedContext : UserDbContext
{ {
Id = 5, Id = 5,
Username = "victor", Username = "victor",
Password = Convert.ToBase64String(KeyDerivation.Pbkdf2( /*Password = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: "Motdepasse", password: "Motdepasse",
salt: RandomNumberGenerator.GetBytes(128 / 8), salt: RandomNumberGenerator.GetBytes(128 / 8),
prf: KeyDerivationPrf.HMACSHA256, prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 100000, iterationCount: 100000,
numBytesRequested: 256 / 8)), numBytesRequested: 256 / 8)),*/
Password = BCryptHelper.HashPassword("Motdepasse", BCryptHelper.GenerateSalt()),
Email = "Victor.GABORIT@etu.uca.fr", Email = "Victor.GABORIT@etu.uca.fr",
IsAdmin = true IsAdmin = true
}); });

@ -11,6 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BCrypt" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Loading…
Cancel
Save