From 82bb85ba9e869719a1a2634cc121bb3e477d17c0 Mon Sep 17 00:00:00 2001 From: Angelo Pirola Date: Mon, 2 Dec 2024 00:02:15 +0100 Subject: [PATCH 1/3] Primo commit AutenticazioneSvc Shared --- .../AutenticazioneSvc.Shared.csproj | 13 +++++++++++++ .../AutenticazioneSvc.Shared/DTO/AuthResponse.cs | 8 ++++++++ .../AutenticazioneSvc.Shared/DTO/LoginRequest.cs | 7 +++++++ .../DTO/RefreshTokenRequest.cs | 7 +++++++ .../AutenticazioneSvc.Shared/DTO/RegisterRequest.cs | 9 +++++++++ .../DTO/RegisterResponse.cs | 7 +++++++ 6 files changed, 51 insertions(+) create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Shared/AutenticazioneSvc.Shared.csproj create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/AuthResponse.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/LoginRequest.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RefreshTokenRequest.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterRequest.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterResponse.cs diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Shared/AutenticazioneSvc.Shared.csproj b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/AutenticazioneSvc.Shared.csproj new file mode 100644 index 0000000..4f78dab --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/AutenticazioneSvc.Shared.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/AuthResponse.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/AuthResponse.cs new file mode 100644 index 0000000..1ba2e42 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/AuthResponse.cs @@ -0,0 +1,8 @@ +namespace AutenticazioneSvc.Shared.DTO; + +public class AuthResponse +{ + public string AccessToken { get; set; } = null!; + public string RefreshToken { get; set; } = null!; + public DateTime ExpiredToken { get; set; } +} \ No newline at end of file diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/LoginRequest.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/LoginRequest.cs new file mode 100644 index 0000000..8cfe79e --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/LoginRequest.cs @@ -0,0 +1,7 @@ +namespace AutenticazioneSvc.Shared.DTO; + +public class LoginRequest +{ + public string UserName { get; set; } = null!; + public string Password { get; set; } = null!; +} \ No newline at end of file diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RefreshTokenRequest.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RefreshTokenRequest.cs new file mode 100644 index 0000000..68ce898 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RefreshTokenRequest.cs @@ -0,0 +1,7 @@ +namespace AutenticazioneSvc.Shared.DTO; + +public class RefreshTokenRequest +{ + public string AccessToken { get; set; } = null!; + public string RefreshToken { get; set; } = null!; +} \ No newline at end of file diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterRequest.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterRequest.cs new file mode 100644 index 0000000..d8e00e7 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterRequest.cs @@ -0,0 +1,9 @@ +namespace AutenticazioneSvc.Shared.DTO; + +public class RegisterRequest +{ + public string FirstName { get; set; } = null!; + public string LastName { get; set; } = null!; + public string Email { get; set; } = null!; + public string Password { get; set; } = null!; +} \ No newline at end of file diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterResponse.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterResponse.cs new file mode 100644 index 0000000..1a22348 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Shared/DTO/RegisterResponse.cs @@ -0,0 +1,7 @@ +namespace AutenticazioneSvc.Shared.DTO; + +public class RegisterResponse +{ + public bool Succeeded { get; set; } + public IEnumerable Errors { get; set; } = []; +} \ No newline at end of file From c3057165cc5a69edf0901116d919ee6efcc8536c Mon Sep 17 00:00:00 2001 From: Angelo Pirola Date: Mon, 2 Dec 2024 00:02:23 +0100 Subject: [PATCH 2/3] Primo commit AutenticazioneSvc Migrations --- .../AutenticazioneSvc.Migrations.csproj | 17 + ...0241126214216_InitialMigration.Designer.cs | 305 ++++++++++++++++++ .../20241126214216_InitialMigration.cs | 227 +++++++++++++ ...41127010320_FixApplicationUser.Designer.cs | 304 +++++++++++++++++ .../20241127010320_FixApplicationUser.cs | 36 +++ .../Migrations/AppDbContextModelSnapshot.cs | 301 +++++++++++++++++ 6 files changed, 1190 insertions(+) create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Migrations/AutenticazioneSvc.Migrations.csproj create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.Designer.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.Designer.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/AppDbContextModelSnapshot.cs diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/AutenticazioneSvc.Migrations.csproj b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/AutenticazioneSvc.Migrations.csproj new file mode 100644 index 0000000..f33cd59 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/AutenticazioneSvc.Migrations.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.Designer.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.Designer.cs new file mode 100644 index 0000000..ee29f06 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.Designer.cs @@ -0,0 +1,305 @@ +// +using System; +using AutenticazioneSvc.DataAccessLayer; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AutenticazioneSvc.Migrations.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241126214216_InitialMigration")] + partial class InitialMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("RefreshToken") + .IsRequired() + .HasColumnType("text"); + + b.Property("RefreshTokenExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUserRole", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", b => + { + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.cs new file mode 100644 index 0000000..a09bd2a --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241126214216_InitialMigration.cs @@ -0,0 +1,227 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AutenticazioneSvc.Migrations.Migrations +{ + /// + public partial class InitialMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + RefreshToken = table.Column(type: "text", nullable: false), + RefreshTokenExpirationDate = table.Column(type: "timestamp with time zone", nullable: true), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + RoleId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + } + } +} diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.Designer.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.Designer.cs new file mode 100644 index 0000000..7a0294f --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.Designer.cs @@ -0,0 +1,304 @@ +// +using System; +using AutenticazioneSvc.DataAccessLayer; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AutenticazioneSvc.Migrations.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20241127010320_FixApplicationUser")] + partial class FixApplicationUser + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("RefreshToken") + .HasColumnType("text"); + + b.Property("RefreshTokenExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUserRole", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", b => + { + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.cs new file mode 100644 index 0000000..cd54363 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/20241127010320_FixApplicationUser.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AutenticazioneSvc.Migrations.Migrations +{ + /// + public partial class FixApplicationUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RefreshToken", + table: "AspNetUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RefreshToken", + table: "AspNetUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + } + } +} diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/AppDbContextModelSnapshot.cs b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..3cec306 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.Migrations/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,301 @@ +// +using System; +using AutenticazioneSvc.DataAccessLayer; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AutenticazioneSvc.Migrations.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("RefreshToken") + .HasColumnType("text"); + + b.Property("RefreshTokenExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUserRole", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationRole", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AutenticazioneSvc.DataAccessLayer.Entities.ApplicationUser", b => + { + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} From a50ed6575c6c4cfeab6a102f12b0988eaddf249f Mon Sep 17 00:00:00 2001 From: Angelo Pirola Date: Mon, 2 Dec 2024 00:02:38 +0100 Subject: [PATCH 3/3] Primo commit AutenticazioneSvc LoadBalancer --- .../AutenticazioneSvc.LoadBalancer.csproj | 13 +++++++ .../AutenticazioneSvc.LoadBalancer/Dockerfile | 20 +++++++++++ .../AutenticazioneSvc.LoadBalancer/Program.cs | 33 +++++++++++++++++ .../Properties/launchSettings.json | 29 +++++++++++++++ .../appsettings.Development.json | 8 +++++ .../appsettings.json | 35 +++++++++++++++++++ 6 files changed, 138 insertions(+) create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Dockerfile create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Program.cs create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Properties/launchSettings.json create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.Development.json create mode 100644 src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.json diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj new file mode 100644 index 0000000..a84815b --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Dockerfile b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Dockerfile new file mode 100644 index 0000000..ddeeb7b --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /app +EXPOSE 5001 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src +COPY ["src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj", "src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/"] +RUN dotnet restore "src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj" +COPY . . + +WORKDIR "/src/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer" +RUN dotnet build "AutenticazioneSvc.LoadBalancer.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "AutenticazioneSvc.LoadBalancer.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "AutenticazioneSvc.LoadBalancer.dll"] \ No newline at end of file diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Program.cs b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Program.cs new file mode 100644 index 0000000..5c60e91 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Server.Kestrel.Core; + +namespace AutenticazioneSvc.LoadBalancer; + +public class Program +{ + /// + /// The main entry point for the application. + /// + /// The command-line arguments. + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add reverse proxy services and load configuration from appsettings + builder.Services.AddReverseProxy() + .LoadFromConfig(builder.Configuration.GetSection("LoadBalancer")); + + // Configure Kestrel server options + builder.Services.Configure(builder.Configuration.GetSection("Kestrel")); + + // Configure route options to use lowercase URLs + builder.Services.Configure(options => options.LowercaseUrls = true); + + var app = builder.Build(); + + // Map reverse proxy routes + app.MapReverseProxy(); + + // Run the application + app.Run(); + } +} \ No newline at end of file diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Properties/launchSettings.json b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Properties/launchSettings.json new file mode 100644 index 0000000..6391ef9 --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:24524", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5083", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.Development.json b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.json b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.json new file mode 100644 index 0000000..4d0e22e --- /dev/null +++ b/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.json @@ -0,0 +1,35 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "LoadBalancer": { + "Routes": { + "route1": { + "ClusterId": "cluster1", + "Match": { + "Path": "{**catch-all}" + } + } + }, + "Clusters": { + "cluster1": { + //"LoadBalancingPolicy": "RoundRobin", + "Destinations": { + "destination1": { + "Address": "http://NOME-DOCKER-API:5001" + } + //"destination1": { + // "Address": "http://[Host]:[Port]/" + //}, + //"destination2": { + // "Address": "http://[Host]:[Port]/" + //} + } + } + } + }, + "AllowedHosts": "*" +} \ No newline at end of file