diff --git a/.gitignore b/.gitignore
index c2a3f28..a5271cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ riderModule.iml
/*.sln.DotSettings.user
*/appsettings.Secret.yml
-*/tempkey.jwk
\ No newline at end of file
+*/tempkey.jwk
+cert
diff --git a/OAuthTest/OAuthTest.csproj b/OAuthTest/OAuthTest.csproj
index c606b82..96de6d6 100644
--- a/OAuthTest/OAuthTest.csproj
+++ b/OAuthTest/OAuthTest.csproj
@@ -1,10 +1,10 @@
- net7.0
+ net10.0
-
+
diff --git a/OAuthTest/Startup.cs b/OAuthTest/Startup.cs
index 0ec8a6a..2fab532 100644
--- a/OAuthTest/Startup.cs
+++ b/OAuthTest/Startup.cs
@@ -24,10 +24,10 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpLogging(logging =>
{
logging.LoggingFields = HttpLoggingFields.All;
- //Write your code to configure the HttpLogging middleware here
+ //Write your code to configure the HttpLogging middleware here
});
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
-
+
services.AddControllersWithViews();
services.AddAuthentication(options =>
@@ -39,15 +39,15 @@ public void ConfigureServices(IServiceCollection services)
.AddOpenIdConnect("oidc", options =>
{
options.SignInScheme = "Cookies";
-
- options.Authority = "https://localhost:5003";
- options.ClientId = "A";
- options.ClientSecret = "A";
+
+ options.Authority = "https://localhost:5001";
+ options.ClientId = "test_client";
+ options.ClientSecret = "test_secret";
options.GetClaimsFromUserInfoEndpoint = true;
options.ResponseType = OpenIdConnectResponseType.Code;
//options.SaveTokens = true;
-
+
options.Scope.Add("profile");
options.Scope.Add("email");
options.ResponseType = "code";
@@ -85,4 +85,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
-}
\ No newline at end of file
+}
diff --git a/README.md b/README.md
index 930c780..455c7b7 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,13 @@ ConnectionStrings:
Mutex:
# Change this to something local on disk.
DbPath: 'C:\Users\Pieter-Jan Briers\Projects\ss14\web\mutex.db'
-```
+```
* Create the mutex DB mentioned above manually, and run `init_mutex.sql` on it. (I recommend https://sqlitebrowser.org/ for this task)
* If I didn't forget anything you should now be able to start both services and it should work:tm:.
+
+### Handling migrations
+The following ef core commands can be used:
+- Creating a migration: `dotnet ef migrations add -p SS14.Auth.Shared`
+- Removing migrations: `dotnet ef migrations remove -p SS14.Auth.Shared --connection ""`
+- Updating the database: `dotnet ef database update -p SS14.Auth.Shared -s .\SS14.Web\ --connection ""`
diff --git a/SS14.Auth.Shared/Data/AccountLogManager.cs b/SS14.Auth.Shared/Data/AccountLogManager.cs
index c067042..a410d2d 100644
--- a/SS14.Auth.Shared/Data/AccountLogManager.cs
+++ b/SS14.Auth.Shared/Data/AccountLogManager.cs
@@ -88,4 +88,4 @@ public AccountLogActor NoActor()
}
}
-public sealed record AccountLogActor(Guid? User, IPAddress? Address);
\ No newline at end of file
+public sealed record AccountLogActor(Guid? User, IPAddress? Address);
diff --git a/SS14.Auth.Shared/Data/ApplicationDbContext.cs b/SS14.Auth.Shared/Data/ApplicationDbContext.cs
index 3b3b507..56e429a 100644
--- a/SS14.Auth.Shared/Data/ApplicationDbContext.cs
+++ b/SS14.Auth.Shared/Data/ApplicationDbContext.cs
@@ -1,9 +1,4 @@
using System;
-using System.Threading.Tasks;
-using IdentityServer4.EntityFramework.Entities;
-using IdentityServer4.EntityFramework.Extensions;
-using IdentityServer4.EntityFramework.Interfaces;
-using IdentityServer4.EntityFramework.Options;
using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
@@ -11,9 +6,7 @@
namespace SS14.Auth.Shared.Data;
public class ApplicationDbContext : IdentityDbContext,
- IDataProtectionKeyContext,
- IConfigurationDbContext,
- IPersistedGrantDbContext
+ IDataProtectionKeyContext
{
public ApplicationDbContext(DbContextOptions options)
: base(options)
@@ -61,10 +54,6 @@ protected override void OnModelCreating(ModelBuilder builder)
.HasIndex(p => p.SpaceUserId)
.IsUnique();
- builder.Entity()
- .HasIndex(p => new { p.ClientId })
- .IsUnique();
-
builder.Entity()
.HasIndex(h => h.ClientData)
.IsUnique();
@@ -72,38 +61,6 @@ protected override void OnModelCreating(ModelBuilder builder)
builder.Entity()
.HasIndex(h => new { h.HwidId, h.SpaceUserId })
.IsUnique();
-
- var cfgStoreOptions = new ConfigurationStoreOptions
- {
- IdentityResource = new TableConfiguration("IdentityResources", "IS4"),
- IdentityResourceClaim = new TableConfiguration("IdentityResourceClaims", "IS4"),
- IdentityResourceProperty = new TableConfiguration("IdentityResourceProperties", "IS4"),
- ApiResource = new TableConfiguration("ApiResources", "IS4"),
- ApiResourceSecret = new TableConfiguration("ApiResourceSecrets", "IS4"),
- ApiResourceScope = new TableConfiguration("ApiResourceScopes", "IS4"),
- ApiResourceClaim = new TableConfiguration("ApiResourceClaims", "IS4"),
- ApiResourceProperty = new TableConfiguration("ApiResourceProperties", "IS4"),
- Client = new TableConfiguration("Clients", "IS4"),
- ClientGrantType = new TableConfiguration("ClientGrantTypes", "IS4"),
- ClientRedirectUri = new TableConfiguration("ClientRedirectUris", "IS4"),
- ClientPostLogoutRedirectUri = new TableConfiguration("ClientPostLogoutRedirectUris", "IS4"),
- ClientScopes = new TableConfiguration("ClientScopes", "IS4"),
- ClientSecret = new TableConfiguration("ClientSecrets", "IS4"),
- ClientClaim = new TableConfiguration("ClientClaims", "IS4"),
- ClientIdPRestriction = new TableConfiguration("ClientIdPRestrictions", "IS4"),
- ClientCorsOrigin = new TableConfiguration("ClientCorsOrigins", "IS4"),
- ClientProperty = new TableConfiguration("ClientProperties", "IS4"),
- ApiScope = new TableConfiguration("ApiScopes", "IS4"),
- ApiScopeClaim = new TableConfiguration("ApiScopeClaims", "IS4"),
- ApiScopeProperty = new TableConfiguration("ApiScopeProperties", "IS4")
- };
- builder.ConfigureClientContext(cfgStoreOptions);
- builder.ConfigureResourcesContext(cfgStoreOptions);
- builder.ConfigurePersistedGrantContext(new OperationalStoreOptions
- {
- PersistedGrants = new TableConfiguration("PersistedGrants", "IS4"),
- DeviceFlowCodes = new TableConfiguration("DeviceCodes", "IS4"),
- });
}
public DbSet ActiveSessions { get; set; }
@@ -113,26 +70,8 @@ protected override void OnModelCreating(ModelBuilder builder)
public DbSet WhitelistEmails { get; set; }
public DbSet Patrons { get; set; }
public DbSet PatreonWebhookLogs { get; set; }
- public DbSet UserOAuthClients { get; set; }
public DbSet PastAccountNames { get; set; }
public DbSet AccountLogs { get; set; }
public DbSet Hwids { get; set; }
public DbSet HwidUsers { get; set; }
-
- // IS4 configuration.
- public DbSet Clients { get; set; }
- public DbSet ClientSecrets { get; set; }
- public DbSet ClientCorsOrigins { get; set; }
- public DbSet IdentityResources { get; set; }
- public DbSet ApiResources { get; set; }
- public DbSet ApiScopes { get; set; }
-
- // IS4 operational.
- public DbSet PersistedGrants { get; set; }
- public DbSet DeviceFlowCodes { get; set; }
-
- Task IPersistedGrantDbContext.SaveChangesAsync()
- {
- return base.SaveChangesAsync();
- }
}
diff --git a/SS14.Auth.Shared/Data/ApplicationDesignTimeDbContextFactory.cs b/SS14.Auth.Shared/Data/ApplicationDesignTimeDbContextFactory.cs
index 9c8635f..41d212b 100644
--- a/SS14.Auth.Shared/Data/ApplicationDesignTimeDbContextFactory.cs
+++ b/SS14.Auth.Shared/Data/ApplicationDesignTimeDbContextFactory.cs
@@ -1,6 +1,7 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
+using static SS14.Auth.Shared.Data.OpeniddictDefaultTypes;
namespace SS14.Auth.Shared.Data;
@@ -11,6 +12,7 @@ public ApplicationDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql("Server=localhost");
+ optionsBuilder.UseOpenIddict();
return new ApplicationDbContext(optionsBuilder.Options);
}
}
diff --git a/SS14.Auth.Shared/Data/Migrations/20250812220730_SwitchToOpenIddict.Designer.cs b/SS14.Auth.Shared/Data/Migrations/20250812220730_SwitchToOpenIddict.Designer.cs
new file mode 100644
index 0000000..5a37830
--- /dev/null
+++ b/SS14.Auth.Shared/Data/Migrations/20250812220730_SwitchToOpenIddict.Designer.cs
@@ -0,0 +1,953 @@
+//
+using System;
+using System.Net;
+using System.Text.Json;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using SS14.Auth.Shared.Data;
+
+#nullable disable
+
+namespace SS14.Auth.Shared.Data.Migrations
+{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20250812220730_SwitchToOpenIddict")]
+ partial class SwitchToOpenIddict
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.8")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("FriendlyName")
+ .HasColumnType("text");
+
+ b.Property("Xml")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("DataProtectionKeys");
+ });
+
+ 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.IdentityUserRole", 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.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("SS14.Auth.Shared.Data.AccountLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Actor")
+ .HasColumnType("uuid");
+
+ b.Property("ActorAddress")
+ .HasColumnType("inet");
+
+ b.Property("Data")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.Property("Time")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SpaceUserId");
+
+ b.ToTable("AccountLogs");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.AuthHash", b =>
+ {
+ b.Property("AuthHashId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuthHashId"));
+
+ b.Property("Expires")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Hash")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property("HwidId")
+ .HasColumnType("bigint");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("AuthHashId");
+
+ b.HasIndex("HwidId");
+
+ b.HasIndex("SpaceUserId");
+
+ b.HasIndex("Hash", "SpaceUserId")
+ .IsUnique();
+
+ b.ToTable("AuthHashes");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.BurnerEmail", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Domain")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Domain")
+ .IsUnique();
+
+ b.ToTable("BurnerEmails");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.Hwid", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClientData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property("TypeCode")
+ .HasColumnType("integer");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientData")
+ .IsUnique();
+
+ b.ToTable("Hwids");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.HwidUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("FirstSeen")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("HwidId")
+ .HasColumnType("bigint");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SpaceUserId");
+
+ b.HasIndex("HwidId", "SpaceUserId")
+ .IsUnique();
+
+ b.ToTable("HwidUsers");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.LoginSession", b =>
+ {
+ b.Property("LoginSessionId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LoginSessionId"));
+
+ b.Property("Expires")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.Property("Token")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.HasKey("LoginSessionId");
+
+ b.HasIndex("SpaceUserId");
+
+ b.HasIndex("Token")
+ .IsUnique();
+
+ b.ToTable("ActiveSessions");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultAuthorization", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("text");
+
+ b.Property("ApplicationId")
+ .HasColumnType("text");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("CreationDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Properties")
+ .HasColumnType("text");
+
+ b.Property("Scopes")
+ .HasColumnType("text");
+
+ b.Property("Status")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Subject")
+ .HasMaxLength(400)
+ .HasColumnType("character varying(400)");
+
+ b.Property("Type")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ApplicationId", "Status", "Subject", "Type");
+
+ b.ToTable("OpenIddictAuthorizations", (string)null);
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultScope", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("text");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Description")
+ .HasColumnType("text");
+
+ b.Property("Descriptions")
+ .HasColumnType("text");
+
+ b.Property("DisplayName")
+ .HasColumnType("text");
+
+ b.Property("DisplayNames")
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("Properties")
+ .HasColumnType("text");
+
+ b.Property("Resources")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("OpenIddictScopes", (string)null);
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultToken", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("text");
+
+ b.Property("ApplicationId")
+ .HasColumnType("text");
+
+ b.Property("AuthorizationId")
+ .HasColumnType("text");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("CreationDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ExpirationDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Payload")
+ .HasColumnType("text");
+
+ b.Property("Properties")
+ .HasColumnType("text");
+
+ b.Property("RedemptionDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ReferenceId")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Status")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Subject")
+ .HasMaxLength(400)
+ .HasColumnType("character varying(400)");
+
+ b.Property("Type")
+ .HasMaxLength(150)
+ .HasColumnType("character varying(150)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AuthorizationId");
+
+ b.HasIndex("ReferenceId")
+ .IsUnique();
+
+ b.HasIndex("ApplicationId", "Status", "Subject", "Type");
+
+ b.ToTable("OpenIddictTokens", (string)null);
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.PastAccountName", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ChangeTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("PastName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SpaceUserId");
+
+ b.ToTable("PastAccountNames");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.PatreonWebhookLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Content")
+ .HasColumnType("jsonb");
+
+ b.Property("Time")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Trigger")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("PatreonWebhookLogs");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.Patron", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CurrentTier")
+ .HasColumnType("text");
+
+ b.Property("PatreonId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PatreonId")
+ .IsUnique();
+
+ b.HasIndex("SpaceUserId")
+ .IsUnique();
+
+ b.ToTable("Patrons");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.SpaceApplication", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("text");
+
+ b.Property("ApplicationType")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("ClientId")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("ClientSecret")
+ .HasColumnType("text");
+
+ b.Property("ClientType")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("ConcurrencyToken")
+ .IsConcurrencyToken()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("ConsentType")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("DisplayName")
+ .HasColumnType("text");
+
+ b.Property("DisplayNames")
+ .HasColumnType("text");
+
+ b.Property("JsonWebKeySet")
+ .HasColumnType("text");
+
+ b.Property("LogoUri")
+ .HasColumnType("text");
+
+ b.Property("Permissions")
+ .HasColumnType("text");
+
+ b.Property("PostLogoutRedirectUris")
+ .HasColumnType("text");
+
+ b.Property("Properties")
+ .HasColumnType("text");
+
+ b.Property("RedirectUris")
+ .HasColumnType("text");
+
+ b.Property("Requirements")
+ .HasColumnType("text");
+
+ b.Property("Settings")
+ .HasColumnType("text");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId")
+ .IsUnique();
+
+ b.HasIndex("SpaceUserId");
+
+ b.ToTable("OpenIddictApplications", (string)null);
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.SpaceRole", 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("SS14.Auth.Shared.Data.SpaceUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AdminLocked")
+ .HasColumnType("boolean");
+
+ b.Property("AdminNotes")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("text");
+
+ b.Property("CreatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property("LastUsernameChange")
+ .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("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("SS14.Auth.Shared.Data.UserOAuthClient", b =>
+ {
+ b.Property("UserOAuthClientId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserOAuthClientId"));
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
+
+ b.Property("SpaceUserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("UserOAuthClientId");
+
+ b.HasIndex("ClientId")
+ .IsUnique();
+
+ b.HasIndex("SpaceUserId");
+
+ b.ToTable("UserOAuthClients");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.WhitelistEmail", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Domain")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Domain")
+ .IsUnique();
+
+ b.ToTable("WhitelistEmails");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.AccountLog", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany("AccountLogs")
+ .HasForeignKey("SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.AuthHash", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.Hwid", "Hwid")
+ .WithMany()
+ .HasForeignKey("HwidId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany("AuthHashes")
+ .HasForeignKey("SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Hwid");
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.HwidUser", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.Hwid", "Hwid")
+ .WithMany("Users")
+ .HasForeignKey("HwidId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany()
+ .HasForeignKey("SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Hwid");
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.LoginSession", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany("LoginSessions")
+ .HasForeignKey("SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultAuthorization", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceApplication", "Application")
+ .WithMany("Authorizations")
+ .HasForeignKey("ApplicationId");
+
+ b.Navigation("Application");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultToken", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceApplication", "Application")
+ .WithMany("Tokens")
+ .HasForeignKey("ApplicationId");
+
+ b.HasOne("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultAuthorization", "Authorization")
+ .WithMany("Tokens")
+ .HasForeignKey("AuthorizationId");
+
+ b.Navigation("Application");
+
+ b.Navigation("Authorization");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.PastAccountName", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany("PastAccountNames")
+ .HasForeignKey("SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.Patron", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithOne("Patron")
+ .HasForeignKey("SS14.Auth.Shared.Data.Patron", "SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.SpaceApplication", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany()
+ .HasForeignKey("SpaceUserId");
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.UserOAuthClient", b =>
+ {
+ b.HasOne("SS14.Auth.Shared.Data.SpaceUser", "SpaceUser")
+ .WithMany()
+ .HasForeignKey("SpaceUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("SpaceUser");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.Hwid", b =>
+ {
+ b.Navigation("Users");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.OpeniddictDefaultTypes+DefaultAuthorization", b =>
+ {
+ b.Navigation("Tokens");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.SpaceApplication", b =>
+ {
+ b.Navigation("Authorizations");
+
+ b.Navigation("Tokens");
+ });
+
+ modelBuilder.Entity("SS14.Auth.Shared.Data.SpaceUser", b =>
+ {
+ b.Navigation("AccountLogs");
+
+ b.Navigation("AuthHashes");
+
+ b.Navigation("LoginSessions");
+
+ b.Navigation("PastAccountNames");
+
+ b.Navigation("Patron");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/SS14.Auth.Shared/Data/Migrations/20250812220730_SwitchToOpenIddict.cs b/SS14.Auth.Shared/Data/Migrations/20250812220730_SwitchToOpenIddict.cs
new file mode 100644
index 0000000..b4131f6
--- /dev/null
+++ b/SS14.Auth.Shared/Data/Migrations/20250812220730_SwitchToOpenIddict.cs
@@ -0,0 +1,998 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace SS14.Auth.Shared.Data.Migrations
+{
+ ///
+ public partial class SwitchToOpenIddict : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ /*migrationBuilder.DropForeignKey(
+ name: "FK_UserOAuthClients_Clients_ClientId",
+ table: "UserOAuthClients");
+
+ migrationBuilder.DropTable(
+ name: "ApiResourceClaims",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiResourceProperties",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiResourceScopes",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiResourceSecrets",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiScopeClaims",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiScopeProperties",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientClaims",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientCorsOrigins",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientGrantTypes",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientIdPRestrictions",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientPostLogoutRedirectUris",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientProperties",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientRedirectUris",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientScopes",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ClientSecrets",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "DeviceCodes",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "IdentityResourceClaims",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "IdentityResourceProperties",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "PersistedGrants",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiResources",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "ApiScopes",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "Clients",
+ schema: "IS4");
+
+ migrationBuilder.DropTable(
+ name: "IdentityResources",
+ schema: "IS4");*/
+
+ migrationBuilder.CreateTable(
+ name: "OpenIddictApplications",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ SpaceUserId = table.Column(type: "uuid", nullable: true),
+ LogoUri = table.Column(type: "text", nullable: true),
+ ApplicationType = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ ClientId = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
+ ClientSecret = table.Column(type: "text", nullable: true),
+ ClientType = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ ConsentType = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ DisplayName = table.Column(type: "text", nullable: true),
+ DisplayNames = table.Column(type: "text", nullable: true),
+ JsonWebKeySet = table.Column(type: "text", nullable: true),
+ Permissions = table.Column(type: "text", nullable: true),
+ PostLogoutRedirectUris = table.Column(type: "text", nullable: true),
+ Properties = table.Column(type: "text", nullable: true),
+ RedirectUris = table.Column(type: "text", nullable: true),
+ Requirements = table.Column(type: "text", nullable: true),
+ Settings = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_OpenIddictApplications", x => x.Id);
+ table.ForeignKey(
+ name: "FK_OpenIddictApplications_AspNetUsers_SpaceUserId",
+ column: x => x.SpaceUserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "OpenIddictScopes",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ Description = table.Column(type: "text", nullable: true),
+ Descriptions = table.Column(type: "text", nullable: true),
+ DisplayName = table.Column(type: "text", nullable: true),
+ DisplayNames = table.Column(type: "text", nullable: true),
+ Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
+ Properties = table.Column(type: "text", nullable: true),
+ Resources = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_OpenIddictScopes", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "OpenIddictAuthorizations",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ ApplicationId = table.Column(type: "text", nullable: true),
+ ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ CreationDate = table.Column(type: "timestamp with time zone", nullable: true),
+ Properties = table.Column(type: "text", nullable: true),
+ Scopes = table.Column(type: "text", nullable: true),
+ Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ Subject = table.Column(type: "character varying(400)", maxLength: 400, nullable: true),
+ Type = table.Column(type: "character varying(50)", maxLength: 50, nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id);
+ table.ForeignKey(
+ name: "FK_OpenIddictAuthorizations_OpenIddictApplications_Application~",
+ column: x => x.ApplicationId,
+ principalTable: "OpenIddictApplications",
+ principalColumn: "Id");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "OpenIddictTokens",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ ApplicationId = table.Column(type: "text", nullable: true),
+ AuthorizationId = table.Column(type: "text", nullable: true),
+ ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ CreationDate = table.Column(type: "timestamp with time zone", nullable: true),
+ ExpirationDate = table.Column(type: "timestamp with time zone", nullable: true),
+ Payload = table.Column(type: "text", nullable: true),
+ Properties = table.Column(type: "text", nullable: true),
+ RedemptionDate = table.Column(type: "timestamp with time zone", nullable: true),
+ ReferenceId = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
+ Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ Subject = table.Column(type: "character varying(400)", maxLength: 400, nullable: true),
+ Type = table.Column(type: "character varying(150)", maxLength: 150, nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_OpenIddictTokens", x => x.Id);
+ table.ForeignKey(
+ name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId",
+ column: x => x.ApplicationId,
+ principalTable: "OpenIddictApplications",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId",
+ column: x => x.AuthorizationId,
+ principalTable: "OpenIddictAuthorizations",
+ principalColumn: "Id");
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictApplications_ClientId",
+ table: "OpenIddictApplications",
+ column: "ClientId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictApplications_SpaceUserId",
+ table: "OpenIddictApplications",
+ column: "SpaceUserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type",
+ table: "OpenIddictAuthorizations",
+ columns: new[] { "ApplicationId", "Status", "Subject", "Type" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictScopes_Name",
+ table: "OpenIddictScopes",
+ column: "Name",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type",
+ table: "OpenIddictTokens",
+ columns: new[] { "ApplicationId", "Status", "Subject", "Type" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictTokens_AuthorizationId",
+ table: "OpenIddictTokens",
+ column: "AuthorizationId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_OpenIddictTokens_ReferenceId",
+ table: "OpenIddictTokens",
+ column: "ReferenceId",
+ unique: true);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "OpenIddictScopes");
+
+ migrationBuilder.DropTable(
+ name: "OpenIddictTokens");
+
+ migrationBuilder.DropTable(
+ name: "OpenIddictAuthorizations");
+
+ migrationBuilder.DropTable(
+ name: "OpenIddictApplications");
+
+ /*migrationBuilder.EnsureSchema(
+ name: "IS4");
+
+ migrationBuilder.CreateTable(
+ name: "ApiResources",
+ schema: "IS4",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ AllowedAccessTokenSigningAlgorithms = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
+ Created = table.Column(type: "timestamp with time zone", nullable: false),
+ Description = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true),
+ DisplayName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
+ Enabled = table.Column(type: "boolean", nullable: false),
+ LastAccessed = table.Column(type: "timestamp with time zone", nullable: true),
+ Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ NonEditable = table.Column(type: "boolean", nullable: false),
+ ShowInDiscoveryDocument = table.Column(type: "boolean", nullable: false),
+ Updated = table.Column(type: "timestamp with time zone", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ApiResources", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ApiScopes",
+ schema: "IS4",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Description = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true),
+ DisplayName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
+ Emphasize = table.Column(type: "boolean", nullable: false),
+ Enabled = table.Column(type: "boolean", nullable: false),
+ Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ Required = table.Column(type: "boolean", nullable: false),
+ ShowInDiscoveryDocument = table.Column(type: "boolean", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ApiScopes", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Clients",
+ schema: "IS4",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ AbsoluteRefreshTokenLifetime = table.Column(type: "integer", nullable: false),
+ AccessTokenLifetime = table.Column(type: "integer", nullable: false),
+ AccessTokenType = table.Column