From 2b3650de1af8eecd28d5de3fea2404ce4adb3966 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Tue, 13 Jan 2026 02:47:09 +0100 Subject: [PATCH] PasswordHasher added --- .../Validators/RegisterRequestValidator.cs | 0 .../Register/{RegisterDto.cs => RegisterData.cs} | 0 .../Application/Commands/Register/RegisterMappers.cs | 10 ++++++++++ .../Application/Helpers/IPasswordHasher.cs | 7 +++++++ .../Application/Helpers/PasswordHashData.cs | 7 +++++++ .../Application/Helpers/PasswordHasher.cs | 6 ++++++ 6 files changed, 30 insertions(+) rename TimetableDesigner.Backend.Services.Authentication/{DTO => API}/Validators/RegisterRequestValidator.cs (100%) rename TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/{RegisterDto.cs => RegisterData.cs} (100%) create mode 100644 TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs create mode 100644 TimetableDesigner.Backend.Services.Authentication/Application/Helpers/IPasswordHasher.cs create mode 100644 TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHashData.cs create mode 100644 TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHasher.cs diff --git a/TimetableDesigner.Backend.Services.Authentication/DTO/Validators/RegisterRequestValidator.cs b/TimetableDesigner.Backend.Services.Authentication/API/Validators/RegisterRequestValidator.cs similarity index 100% rename from TimetableDesigner.Backend.Services.Authentication/DTO/Validators/RegisterRequestValidator.cs rename to TimetableDesigner.Backend.Services.Authentication/API/Validators/RegisterRequestValidator.cs diff --git a/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterDto.cs b/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterData.cs similarity index 100% rename from TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterDto.cs rename to TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterData.cs diff --git a/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs b/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs new file mode 100644 index 0000000..3317d95 --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs @@ -0,0 +1,10 @@ +using TimetableDesigner.Backend.Services.Authentication.Application.Commands.Register; +using TimetableDesigner.Backend.Services.Authentication.DTO.API; + +namespace TimetableDesigner.Backend.Services.Authentication.DTO.Mappers; + +public static class RegisterMappers +{ + public static RegisterCommand ToCommand(this RegisterRequest request) => + new RegisterCommand(request.Email, request.Password); +} \ No newline at end of file diff --git a/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/IPasswordHasher.cs b/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/IPasswordHasher.cs new file mode 100644 index 0000000..36e1119 --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/IPasswordHasher.cs @@ -0,0 +1,7 @@ +namespace TimetableDesigner.Backend.Services.Authentication.Application.Helpers; + +public interface IPasswordHasher +{ + PasswordHashData CreateHash(string password); + byte[] ComputeHash(string password, string salt); +} \ No newline at end of file diff --git a/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHashData.cs b/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHashData.cs new file mode 100644 index 0000000..cb01f57 --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHashData.cs @@ -0,0 +1,7 @@ +namespace TimetableDesigner.Backend.Services.Authentication.Application.Helpers; + +public record PasswordHashData( + byte[] Hash, + string LeftSalt, + string RightSalt +); \ No newline at end of file diff --git a/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHasher.cs b/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHasher.cs new file mode 100644 index 0000000..96f7d5c --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication/Application/Helpers/PasswordHasher.cs @@ -0,0 +1,6 @@ +namespace TimetableDesigner.Backend.Services.Authentication.Application.Helpers; + +public class PasswordHasher +{ + +} \ No newline at end of file