diff --git a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/20261111192531_FixAuthenticationSecurityStateUniqueness.Designer.cs b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/20261111192531_FixAuthenticationSecurityStateUniqueness.Designer.cs
new file mode 100644
index 00000000..0708b188
--- /dev/null
+++ b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/20261111192531_FixAuthenticationSecurityStateUniqueness.Designer.cs
@@ -0,0 +1,780 @@
+//
+using System;
+using CodeBeam.UltimateAuth.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace CodeBeam.UltimateAuth.IdentityLab.Migrations
+{
+ [DbContext(typeof(UAuthDbContext))]
+ [Migration("20261111192531_FixAuthenticationSecurityStateUniqueness")]
+ partial class FixAuthenticationSecurityStateUniqueness
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.14")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore.AuthenticationSecurityStateProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CredentialType")
+ .HasColumnType("integer");
+
+ b.Property("FailedAttempts")
+ .HasColumnType("integer");
+
+ b.Property("LastFailedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("LockedUntil")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RequiresReauthentication")
+ .HasColumnType("boolean");
+
+ b.Property("ResetAttempts")
+ .HasColumnType("integer");
+
+ b.Property("ResetConsumedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ResetExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ResetRequestedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ResetTokenHash")
+ .HasMaxLength(512)
+ .HasColumnType("character varying(512)");
+
+ b.Property("Scope")
+ .HasColumnType("integer");
+
+ b.Property("SecurityVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "LockedUntil");
+
+ b.HasIndex("Tenant", "ResetRequestedAt");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "Scope");
+
+ b.HasIndex("Tenant", "UserKey", "Scope", "CredentialType")
+ .IsUnique();
+
+ NpgsqlIndexBuilderExtensions.AreNullsDistinct(b.HasIndex("Tenant", "UserKey", "Scope", "CredentialType"), false);
+
+ b.ToTable("UAuth_Authentication", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.RolePermissionProjection", b =>
+ {
+ b.Property("Tenant")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.Property("Permission")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.HasKey("Tenant", "RoleId", "Permission");
+
+ b.HasIndex("Tenant", "Permission");
+
+ b.HasIndex("Tenant", "RoleId");
+
+ b.ToTable("UAuth_RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.RoleProjection", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("NormalizedName")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "Id")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "NormalizedName")
+ .IsUnique();
+
+ b.ToTable("UAuth_Roles", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.UserRoleProjection", b =>
+ {
+ b.Property("Tenant")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UserKey")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.Property("AssignedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Tenant", "UserKey", "RoleId");
+
+ b.HasIndex("Tenant", "RoleId");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.ToTable("UAuth_UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.PasswordCredentialProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RevokedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SecretHash")
+ .IsRequired()
+ .HasMaxLength(512)
+ .HasColumnType("character varying(512)");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("uuid");
+
+ b.Property("Source")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ExpiresAt");
+
+ b.HasIndex("Tenant", "Id")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "RevokedAt");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "DeletedAt");
+
+ b.ToTable("UAuth_PasswordCredentials", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.PasswordHistoryProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CredentialId")
+ .HasColumnType("uuid");
+
+ b.Property("ReplacedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SecretHash")
+ .IsRequired()
+ .HasMaxLength(512)
+ .HasColumnType("character varying(512)");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "CredentialId", "ReplacedAt", "Id");
+
+ b.ToTable("UAuth_PasswordHistory", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionChainProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("AbsoluteExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ActiveSessionId")
+ .HasColumnType("text");
+
+ b.Property("ChainId")
+ .HasColumnType("uuid");
+
+ b.Property("ClaimsSnapshot")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Device")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("DeviceId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("LastSeenAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RevokedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RootId")
+ .HasColumnType("uuid");
+
+ b.Property("RotationCount")
+ .HasColumnType("integer");
+
+ b.Property("SecurityVersionAtCreation")
+ .HasColumnType("bigint");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("TouchCount")
+ .HasColumnType("integer");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ChainId")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "RootId");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "DeviceId");
+
+ b.ToTable("UAuth_SessionChains", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ChainId")
+ .HasColumnType("uuid");
+
+ b.Property("Claims")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Device")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Metadata")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RevokedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SecurityVersionAtCreation")
+ .HasColumnType("bigint");
+
+ b.Property("SessionId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ChainId");
+
+ b.HasIndex("Tenant", "ExpiresAt");
+
+ b.HasIndex("Tenant", "RevokedAt");
+
+ b.HasIndex("Tenant", "SessionId")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "ChainId", "RevokedAt");
+
+ b.HasIndex("Tenant", "UserKey", "RevokedAt");
+
+ b.ToTable("UAuth_Sessions", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionRootProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RevokedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RootId")
+ .HasMaxLength(128)
+ .HasColumnType("uuid");
+
+ b.Property("SecurityVersion")
+ .HasColumnType("bigint");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "RootId")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "RevokedAt");
+
+ b.ToTable("UAuth_SessionRoots", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore.RefreshTokenProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ChainId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ReplacedByTokenHash")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("RevokedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SessionId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("TokenHash")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("TokenId")
+ .HasColumnType("uuid");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ChainId");
+
+ b.HasIndex("Tenant", "ExpiresAt");
+
+ b.HasIndex("Tenant", "ReplacedByTokenHash");
+
+ b.HasIndex("Tenant", "SessionId");
+
+ b.HasIndex("Tenant", "TokenHash")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "TokenId");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "ExpiresAt", "RevokedAt");
+
+ b.HasIndex("Tenant", "TokenHash", "RevokedAt");
+
+ b.ToTable("UAuth_RefreshTokens", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Users.EntityFrameworkCore.UserIdentifierProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property("NormalizedValue")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("VerifiedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "NormalizedValue");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "Type", "NormalizedValue")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "UserKey", "IsPrimary");
+
+ b.HasIndex("Tenant", "UserKey", "Type", "IsPrimary", "DeletedAt", "CreatedAt", "Id");
+
+ b.ToTable("UAuth_UserIdentifiers", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Users.EntityFrameworkCore.UserLifecycleProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SecurityVersion")
+ .HasColumnType("bigint");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "UserKey")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "DeletedAt", "CreatedAt", "Id");
+
+ b.HasIndex("Tenant", "Status", "DeletedAt", "CreatedAt", "Id");
+
+ b.ToTable("UAuth_UserLifecycles", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Users.EntityFrameworkCore.UserProfileProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Bio")
+ .HasMaxLength(4096)
+ .HasColumnType("character varying(4096)");
+
+ b.Property("BirthDate")
+ .HasColumnType("date");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Culture")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DisplayName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("FirstName")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Gender")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Language")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("LastName")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Metadata")
+ .HasColumnType("text");
+
+ b.Property("ProfileKey")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("TimeZone")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "UserKey", "ProfileKey")
+ .IsUnique();
+
+ b.ToTable("UAuth_UserProfiles", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionChainProjection", b =>
+ {
+ b.HasOne("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionRootProjection", null)
+ .WithMany()
+ .HasForeignKey("Tenant", "RootId")
+ .HasPrincipalKey("Tenant", "RootId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionProjection", b =>
+ {
+ b.HasOne("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionChainProjection", null)
+ .WithMany()
+ .HasForeignKey("Tenant", "ChainId")
+ .HasPrincipalKey("Tenant", "ChainId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/20261111192531_FixAuthenticationSecurityStateUniqueness.cs b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/20261111192531_FixAuthenticationSecurityStateUniqueness.cs
new file mode 100644
index 00000000..99fcee52
--- /dev/null
+++ b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/20261111192531_FixAuthenticationSecurityStateUniqueness.cs
@@ -0,0 +1,39 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodeBeam.UltimateAuth.IdentityLab.Migrations
+{
+ ///
+ public partial class FixAuthenticationSecurityStateUniqueness : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_UAuth_Authentication_Tenant_UserKey_Scope_CredentialType",
+ table: "UAuth_Authentication");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UAuth_Authentication_Tenant_UserKey_Scope_CredentialType",
+ table: "UAuth_Authentication",
+ columns: new[] { "Tenant", "UserKey", "Scope", "CredentialType" },
+ unique: true)
+ .Annotation("Npgsql:NullsDistinct", false);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_UAuth_Authentication_Tenant_UserKey_Scope_CredentialType",
+ table: "UAuth_Authentication");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UAuth_Authentication_Tenant_UserKey_Scope_CredentialType",
+ table: "UAuth_Authentication",
+ columns: new[] { "Tenant", "UserKey", "Scope", "CredentialType" },
+ unique: true);
+ }
+ }
+}
diff --git a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/UAuthDbContextModelSnapshot.cs b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/UAuthDbContextModelSnapshot.cs
index 55d8efe3..2e3c58e4 100644
--- a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/UAuthDbContextModelSnapshot.cs
+++ b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Migrations/UAuthDbContextModelSnapshot.cs
@@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "10.0.12")
+ .HasAnnotation("ProductVersion", "10.0.14")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -89,6 +89,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("Tenant", "UserKey", "Scope", "CredentialType")
.IsUnique();
+ NpgsqlIndexBuilderExtensions.AreNullsDistinct(b.HasIndex("Tenant", "UserKey", "Scope", "CredentialType"), false);
+
b.ToTable("UAuth_Authentication", (string)null);
});
diff --git a/samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore/Migrations/20261111192825_FixAuthenticationSecurityStateUniqueness.Designer.cs b/samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore/Migrations/20261111192825_FixAuthenticationSecurityStateUniqueness.Designer.cs
new file mode 100644
index 00000000..1ca04a07
--- /dev/null
+++ b/samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore/Migrations/20261111192825_FixAuthenticationSecurityStateUniqueness.Designer.cs
@@ -0,0 +1,766 @@
+//
+using System;
+using CodeBeam.UltimateAuth.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore.Migrations
+{
+ [DbContext(typeof(UAuthDbContext))]
+ [Migration("20261111192825_FixAuthenticationSecurityStateUniqueness")]
+ partial class FixAuthenticationSecurityStateUniqueness
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.14");
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore.AuthenticationSecurityStateProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CredentialType")
+ .HasColumnType("INTEGER");
+
+ b.Property("FailedAttempts")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastFailedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("LockedUntil")
+ .HasColumnType("TEXT");
+
+ b.Property("RequiresReauthentication")
+ .HasColumnType("INTEGER");
+
+ b.Property("ResetAttempts")
+ .HasColumnType("INTEGER");
+
+ b.Property("ResetConsumedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ResetExpiresAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ResetRequestedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ResetTokenHash")
+ .HasMaxLength(512)
+ .HasColumnType("TEXT");
+
+ b.Property("Scope")
+ .HasColumnType("INTEGER");
+
+ b.Property("SecurityVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "LockedUntil");
+
+ b.HasIndex("Tenant", "ResetRequestedAt");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "Scope");
+
+ b.HasIndex("Tenant", "UserKey", "Scope", "CredentialType")
+ .IsUnique()
+ .HasAnnotation("Npgsql:NullsDistinct", false);
+
+ b.ToTable("UAuth_Authentication", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.RolePermissionProjection", b =>
+ {
+ b.Property("Tenant")
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("Permission")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Tenant", "RoleId", "Permission");
+
+ b.HasIndex("Tenant", "Permission");
+
+ b.HasIndex("Tenant", "RoleId");
+
+ b.ToTable("UAuth_RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.RoleProjection", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("DeletedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedName")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "Id")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "NormalizedName")
+ .IsUnique();
+
+ b.ToTable("UAuth_Roles", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.UserRoleProjection", b =>
+ {
+ b.Property("Tenant")
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("AssignedAt")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Tenant", "UserKey", "RoleId");
+
+ b.HasIndex("Tenant", "RoleId");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.ToTable("UAuth_UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.PasswordCredentialProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("DeletedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("TEXT");
+
+ b.Property("LastUsedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("RevokedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("SecretHash")
+ .IsRequired()
+ .HasMaxLength(512)
+ .HasColumnType("TEXT");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("Source")
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ExpiresAt");
+
+ b.HasIndex("Tenant", "Id")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "RevokedAt");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "DeletedAt");
+
+ b.ToTable("UAuth_PasswordCredentials", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.PasswordHistoryProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CredentialId")
+ .HasColumnType("TEXT");
+
+ b.Property("ReplacedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("SecretHash")
+ .IsRequired()
+ .HasMaxLength(512)
+ .HasColumnType("TEXT");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "CredentialId", "ReplacedAt", "Id");
+
+ b.ToTable("UAuth_PasswordHistory", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionChainProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AbsoluteExpiresAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ActiveSessionId")
+ .HasColumnType("TEXT");
+
+ b.Property("ChainId")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimsSnapshot")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Device")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("TEXT");
+
+ b.Property("LastSeenAt")
+ .HasColumnType("TEXT");
+
+ b.Property("RevokedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("RootId")
+ .HasColumnType("TEXT");
+
+ b.Property("RotationCount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SecurityVersionAtCreation")
+ .HasColumnType("INTEGER");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("TouchCount")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ChainId")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "RootId");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "DeviceId");
+
+ b.ToTable("UAuth_SessionChains", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ChainId")
+ .HasColumnType("TEXT");
+
+ b.Property("Claims")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Device")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Metadata")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RevokedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("SecurityVersionAtCreation")
+ .HasColumnType("INTEGER");
+
+ b.Property("SessionId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ChainId");
+
+ b.HasIndex("Tenant", "ExpiresAt");
+
+ b.HasIndex("Tenant", "RevokedAt");
+
+ b.HasIndex("Tenant", "SessionId")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "ChainId", "RevokedAt");
+
+ b.HasIndex("Tenant", "UserKey", "RevokedAt");
+
+ b.ToTable("UAuth_Sessions", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.SessionRootProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("RevokedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("RootId")
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("SecurityVersion")
+ .HasColumnType("INTEGER");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "RootId")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "UserKey", "RevokedAt");
+
+ b.ToTable("UAuth_SessionRoots", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore.RefreshTokenProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ChainId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("TEXT");
+
+ b.Property("ReplacedByTokenHash")
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("RevokedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("SessionId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("TokenHash")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("TokenId")
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant", "ChainId");
+
+ b.HasIndex("Tenant", "ExpiresAt");
+
+ b.HasIndex("Tenant", "ReplacedByTokenHash");
+
+ b.HasIndex("Tenant", "SessionId");
+
+ b.HasIndex("Tenant", "TokenHash")
+ .IsUnique();
+
+ b.HasIndex("Tenant", "TokenId");
+
+ b.HasIndex("Tenant", "UserKey");
+
+ b.HasIndex("Tenant", "ExpiresAt", "RevokedAt");
+
+ b.HasIndex("Tenant", "TokenHash", "RevokedAt");
+
+ b.ToTable("UAuth_RefreshTokens", (string)null);
+ });
+
+ modelBuilder.Entity("CodeBeam.UltimateAuth.Users.EntityFrameworkCore.UserIdentifierProjection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("DeletedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("IsPrimary")
+ .HasColumnType("INTEGER");
+
+ b.Property("NormalizedValue")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("Tenant")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("UserKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("VerifiedAt")
+ .HasColumnType("TEXT");
+
+ b.Property