diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticatePasswordRequest.cs b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticatePasswordRequest.cs similarity index 95% rename from TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticatePasswordRequest.cs rename to TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticatePasswordRequest.cs index d16b8eb..7759faa 100644 --- a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticatePasswordRequest.cs +++ b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticatePasswordRequest.cs @@ -1,4 +1,4 @@ -namespace TimetableDesigner.Backend.Services.Authentication.DTO.API; +namespace TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; public class AuthenticatePasswordRequest { diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticateResponse.cs b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticateResponse.cs similarity index 95% rename from TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticateResponse.cs rename to TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticateResponse.cs index 76ed6e6..e173528 100644 --- a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticateResponse.cs +++ b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticateResponse.cs @@ -1,4 +1,4 @@ -namespace TimetableDesigner.Backend.Services.Authentication.DTO.API; +namespace TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; public class AuthenticateResponse { diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticateTokenRequest.cs b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticateTokenRequest.cs similarity index 95% rename from TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticateTokenRequest.cs rename to TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticateTokenRequest.cs index a964371..daaaaed 100644 --- a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/AuthenticateTokenRequest.cs +++ b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/AuthenticateTokenRequest.cs @@ -1,4 +1,4 @@ -namespace TimetableDesigner.Backend.Services.Authentication.DTO.API; +namespace TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; public class AuthenticateTokenRequest { diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/RegisterRequest.cs b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/RegisterRequest.cs similarity index 93% rename from TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/RegisterRequest.cs rename to TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/RegisterRequest.cs index cc6973d..1180d9b 100644 --- a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/RegisterRequest.cs +++ b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/RegisterRequest.cs @@ -1,4 +1,4 @@ -namespace TimetableDesigner.Backend.Services.Authentication.DTO.API; +namespace TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; public record RegisterRequest( string Email, diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/RegisterResponse.cs b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/RegisterResponse.cs similarity index 92% rename from TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/RegisterResponse.cs rename to TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/RegisterResponse.cs index 3001dd5..283127c 100644 --- a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/RegisterResponse.cs +++ b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/RegisterResponse.cs @@ -1,4 +1,4 @@ -namespace TimetableDesigner.Backend.Services.Authentication.DTO.API; +namespace TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; public record RegisterResponse( long Id, diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/TimetableDesigner.Backend.Services.Authentication.DTO.API.csproj b/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI.csproj similarity index 100% rename from TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.API/TimetableDesigner.Backend.Services.Authentication.DTO.API.csproj rename to TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI/TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI.csproj diff --git a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.Events/TimetableDesigner.Backend.Services.Authentication.DTO.Events.csproj b/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.Events/TimetableDesigner.Backend.Services.Authentication.DTO.Events.csproj deleted file mode 100644 index 237d661..0000000 --- a/TimetableDesigner.Backend.Services.Authentication.DTO/TimetableDesigner.Backend.Services.Authentication.DTO.Events/TimetableDesigner.Backend.Services.Authentication.DTO.Events.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net10.0 - enable - enable - - - diff --git a/TimetableDesigner.Backend.Services.Authentication.sln b/TimetableDesigner.Backend.Services.Authentication.sln deleted file mode 100644 index 1a43359..0000000 --- a/TimetableDesigner.Backend.Services.Authentication.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.Backend.Services.Authentication", "TimetableDesigner.Backend.Services.Authentication\TimetableDesigner.Backend.Services.Authentication.csproj", "{F8C0AEF3-B53F-4904-90F7-EE4A8587F023}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TimetableDesigner.Backend.Services.Authentication.DTO", "TimetableDesigner.Backend.Services.Authentication.DTO", "{B610971F-EF8F-45D2-B869-41617ED447C8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.Backend.Services.Authentication.DTO.API", "TimetableDesigner.Backend.Services.Authentication.DTO\TimetableDesigner.Backend.Services.Authentication.DTO.API\TimetableDesigner.Backend.Services.Authentication.DTO.API.csproj", "{0639DAB9-E1B4-454E-A3E9-F7B712A697E8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.Backend.Services.Authentication.DTO.Events", "TimetableDesigner.Backend.Services.Authentication.DTO\TimetableDesigner.Backend.Services.Authentication.DTO.Events\TimetableDesigner.Backend.Services.Authentication.DTO.Events.csproj", "{3E39EDEE-621F-49BC-B777-174BB047BCA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F8C0AEF3-B53F-4904-90F7-EE4A8587F023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8C0AEF3-B53F-4904-90F7-EE4A8587F023}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8C0AEF3-B53F-4904-90F7-EE4A8587F023}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8C0AEF3-B53F-4904-90F7-EE4A8587F023}.Release|Any CPU.Build.0 = Release|Any CPU - {0639DAB9-E1B4-454E-A3E9-F7B712A697E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0639DAB9-E1B4-454E-A3E9-F7B712A697E8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0639DAB9-E1B4-454E-A3E9-F7B712A697E8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0639DAB9-E1B4-454E-A3E9-F7B712A697E8}.Release|Any CPU.Build.0 = Release|Any CPU - {3E39EDEE-621F-49BC-B777-174BB047BCA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E39EDEE-621F-49BC-B777-174BB047BCA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E39EDEE-621F-49BC-B777-174BB047BCA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E39EDEE-621F-49BC-B777-174BB047BCA7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {0639DAB9-E1B4-454E-A3E9-F7B712A697E8} = {B610971F-EF8F-45D2-B869-41617ED447C8} - {3E39EDEE-621F-49BC-B777-174BB047BCA7} = {B610971F-EF8F-45D2-B869-41617ED447C8} - EndGlobalSection -EndGlobal diff --git a/TimetableDesigner.Backend.Services.Authentication.slnx b/TimetableDesigner.Backend.Services.Authentication.slnx new file mode 100644 index 0000000..6654fd0 --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication.slnx @@ -0,0 +1,5 @@ + + + + + diff --git a/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs b/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs index 28f95ae..813e8d5 100644 --- a/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs +++ b/TimetableDesigner.Backend.Services.Authentication/Application/Commands/Register/RegisterMappers.cs @@ -1,5 +1,5 @@ using TimetableDesigner.Backend.Services.Authentication.Database.Model; -using TimetableDesigner.Backend.Services.Authentication.DTO.API; +using TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; namespace TimetableDesigner.Backend.Services.Authentication.Application.Commands.Register; diff --git a/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/20260114231600_Account changes.Designer.cs b/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/20260114231600_Account changes.Designer.cs new file mode 100644 index 0000000..5b06749 --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/20260114231600_Account changes.Designer.cs @@ -0,0 +1,114 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TimetableDesigner.Backend.Services.Authentication.Database; + +#nullable disable + +namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20260114231600_Account changes")] + partial class Accountchanges + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(320) + .HasColumnType("character varying(320)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("bytea"); + + b.Property("PasswordSalt") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.RefreshToken", b => + { + b.Property("Token") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsExtendable") + .HasColumnType("boolean"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Token"); + + b.HasIndex("AccountId"); + + b.HasIndex("Token") + .IsUnique(); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.RefreshToken", b => + { + b.HasOne("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", "Account") + .WithMany("RefreshTokens") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", b => + { + b.Navigation("RefreshTokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/20260114231600_Account changes.cs b/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/20260114231600_Account changes.cs new file mode 100644 index 0000000..8a7ce9c --- /dev/null +++ b/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/20260114231600_Account changes.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations +{ + /// + public partial class Accountchanges : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PasswordSaltLeft", + table: "Accounts"); + + migrationBuilder.RenameColumn( + name: "PasswordSaltRight", + table: "Accounts", + newName: "PasswordSalt"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "PasswordSalt", + table: "Accounts", + newName: "PasswordSaltRight"); + + migrationBuilder.AddColumn( + name: "PasswordSaltLeft", + table: "Accounts", + type: "character varying(20)", + maxLength: 20, + nullable: false, + defaultValue: ""); + } + } +} diff --git a/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/DatabaseContextModelSnapshot.cs b/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/DatabaseContextModelSnapshot.cs index 63e4122..bed91a8 100644 --- a/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/TimetableDesigner.Backend.Services.Authentication/Database/Migrations/DatabaseContextModelSnapshot.cs @@ -40,12 +40,7 @@ namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations .HasMaxLength(1000) .HasColumnType("bytea"); - b.Property("PasswordSaltLeft") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("PasswordSaltRight") + b.Property("PasswordSalt") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)"); diff --git a/TimetableDesigner.Backend.Services.Authentication/Program.cs b/TimetableDesigner.Backend.Services.Authentication/Program.cs index 132ed8f..70d70e3 100644 --- a/TimetableDesigner.Backend.Services.Authentication/Program.cs +++ b/TimetableDesigner.Backend.Services.Authentication/Program.cs @@ -2,6 +2,8 @@ using System.Reflection; using FluentValidation; using Microsoft.AspNetCore.Identity.Data; using Microsoft.EntityFrameworkCore; +using TimetableDesigner.Backend.Events; +using TimetableDesigner.Backend.Events.RabbitMQ; using TimetableDesigner.Backend.Services.Authentication.API; using TimetableDesigner.Backend.Services.Authentication.API.Validators; using TimetableDesigner.Backend.Services.Authentication.Application.Helpers; @@ -33,6 +35,13 @@ public static class Program private static WebApplicationBuilder SetupOpenApi(this WebApplicationBuilder builder) { + builder.Services.AddEventQueue(cfg => + { + cfg.Hostname = "localhost"; + cfg.Port = 5672; + cfg.Username = "user"; + cfg.Password = "l4JxOIuSoyod86N"; + }); builder.Services.AddOpenApi(); return builder; } @@ -57,7 +66,7 @@ public static class Program private static WebApplicationBuilder SetupValidation(this WebApplicationBuilder builder) { - builder.Services.AddScoped, RegisterRequestValidator>(); + builder.Services.AddScoped, RegisterRequestValidator>(); return builder; } diff --git a/TimetableDesigner.Backend.Services.Authentication/TimetableDesigner.Backend.Services.Authentication.csproj b/TimetableDesigner.Backend.Services.Authentication/TimetableDesigner.Backend.Services.Authentication.csproj index 2df7f22..27f76da 100644 --- a/TimetableDesigner.Backend.Services.Authentication/TimetableDesigner.Backend.Services.Authentication.csproj +++ b/TimetableDesigner.Backend.Services.Authentication/TimetableDesigner.Backend.Services.Authentication.csproj @@ -21,7 +21,8 @@ - + + diff --git a/TimetableDesigner.Backend.Services.Authentication/API/Endpoints.cs b/TimetableDesigner.Backend.Services.Authentication/WebAPI/Endpoints.cs similarity index 96% rename from TimetableDesigner.Backend.Services.Authentication/API/Endpoints.cs rename to TimetableDesigner.Backend.Services.Authentication/WebAPI/Endpoints.cs index 2d97ac0..f0c14d2 100644 --- a/TimetableDesigner.Backend.Services.Authentication/API/Endpoints.cs +++ b/TimetableDesigner.Backend.Services.Authentication/WebAPI/Endpoints.cs @@ -4,7 +4,7 @@ using MediatR; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; using TimetableDesigner.Backend.Services.Authentication.Application.Commands.Register; -using TimetableDesigner.Backend.Services.Authentication.DTO.API; +using TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; namespace TimetableDesigner.Backend.Services.Authentication.API; diff --git a/TimetableDesigner.Backend.Services.Authentication/API/Validators/RegisterRequestValidator.cs b/TimetableDesigner.Backend.Services.Authentication/WebAPI/Validators/RegisterRequestValidator.cs similarity index 95% rename from TimetableDesigner.Backend.Services.Authentication/API/Validators/RegisterRequestValidator.cs rename to TimetableDesigner.Backend.Services.Authentication/WebAPI/Validators/RegisterRequestValidator.cs index 0f07425..32d5d76 100644 --- a/TimetableDesigner.Backend.Services.Authentication/API/Validators/RegisterRequestValidator.cs +++ b/TimetableDesigner.Backend.Services.Authentication/WebAPI/Validators/RegisterRequestValidator.cs @@ -1,7 +1,7 @@ using FluentValidation; using Microsoft.EntityFrameworkCore; using TimetableDesigner.Backend.Services.Authentication.Database; -using TimetableDesigner.Backend.Services.Authentication.DTO.API; +using TimetableDesigner.Backend.Services.Authentication.DTO.WebAPI; namespace TimetableDesigner.Backend.Services.Authentication.API.Validators;