Users can now registers and get a One Time Token Access Code

This commit is contained in:
Zoe Roux 2020-03-06 01:04:29 +01:00
parent 4ed7451004
commit 520aca1278
21 changed files with 4720 additions and 31 deletions

View File

@ -1,7 +1,11 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using IdentityServer4.EntityFramework.DbContexts;
using IdentityServer4.EntityFramework.Mappers;
using IdentityServer4.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -20,12 +24,30 @@ namespace Kyoo.Controllers
{
using (IServiceScope serviceScope = _serviceProvider.CreateScope())
{
serviceScope.ServiceProvider.GetService<DatabaseContext>().Database.EnsureCreated();
serviceScope.ServiceProvider.GetService<ConfigurationDbContext>().Database.EnsureCreated();
serviceScope.ServiceProvider.GetService<PersistedGrantDbContext>().Database.EnsureCreated();
// Use the next line if the database is not SQLite (SQLite doesn't support complexe migrations).
// serviceScope.ServiceProvider.GetService<DatabaseContext>().Database.Migrate();;
serviceScope.ServiceProvider.GetService<DatabaseContext>().Database.Migrate();;
serviceScope.ServiceProvider.GetService<PersistedGrantDbContext>().Database.Migrate();
ConfigurationDbContext identityContext = serviceScope.ServiceProvider.GetService<ConfigurationDbContext>();
identityContext.Database.Migrate();
if (!identityContext.Clients.Any())
{
foreach (Client client in IdentityContext.GetClients())
identityContext.Clients.Add(client.ToEntity());
identityContext.SaveChanges();
}
if (!identityContext.IdentityResources.Any())
{
foreach (IdentityResource resource in IdentityContext.GetIdentityResources())
identityContext.IdentityResources.Add(resource.ToEntity());
identityContext.SaveChanges();
}
if (!identityContext.ApiResources.Any())
{
foreach (ApiResource resource in IdentityContext.GetApis())
identityContext.ApiResources.Add(resource.ToEntity());
identityContext.SaveChanges();
}
IPluginManager pluginManager = serviceScope.ServiceProvider.GetService<IPluginManager>();
pluginManager.ReloadPlugins();

View File

@ -25,6 +25,7 @@
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.2" />
@ -87,6 +88,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Models\DatabaseMigrations\IdentityPeristant" />
</ItemGroup>
<Target Name="CreatePluginFolder" AfterTargets="Build">
<MakeDir Directories="$(OutputPath)/plugins" />

22
Kyoo/Models/Account.cs Normal file
View File

@ -0,0 +1,22 @@
using System;
using IdentityModel;
using Microsoft.AspNetCore.Identity;
namespace Kyoo.Models
{
public class Account : IdentityUser
{
public string OTAC { get; set; }
public DateTime? OTACExpires { get; set; }
public string GenerateOTAC(TimeSpan validFor)
{
string otac = CryptoRandom.CreateUniqueId();
string hashed = otac; // TODO should add a good hashing here.
OTAC = hashed;
OTACExpires = DateTime.UtcNow.Add(validFor);
return otac;
}
}
}

View File

@ -11,6 +11,8 @@ namespace Kyoo
{
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
public DbSet<Account> Accounts { get; set; }
public DbSet<Library> Libraries { get; set; }
public DbSet<Collection> Collections { get; set; }
public DbSet<Show> Shows { get; set; }

View File

@ -0,0 +1,813 @@
// <auto-generated />
using System;
using IdentityServer4.EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations
{
[DbContext(typeof(ConfigurationDbContext))]
[Migration("20200303213949_IS_Configuration")]
partial class IS_Configuration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResource", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Enabled")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LastAccessed")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("NonEditable")
.HasColumnType("INTEGER");
b.Property<DateTime?>("Updated")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("ApiResources");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.ToTable("ApiClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.ToTable("ApiProperties");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Required")
.HasColumnType("INTEGER");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("ApiScopes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiScopeId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ApiScopeId");
b.ToTable("ApiScopeClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<DateTime?>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(4000);
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.ToTable("ApiSecrets");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AbsoluteRefreshTokenLifetime")
.HasColumnType("INTEGER");
b.Property<int>("AccessTokenLifetime")
.HasColumnType("INTEGER");
b.Property<int>("AccessTokenType")
.HasColumnType("INTEGER");
b.Property<bool>("AllowAccessTokensViaBrowser")
.HasColumnType("INTEGER");
b.Property<bool>("AllowOfflineAccess")
.HasColumnType("INTEGER");
b.Property<bool>("AllowPlainTextPkce")
.HasColumnType("INTEGER");
b.Property<bool>("AllowRememberConsent")
.HasColumnType("INTEGER");
b.Property<bool>("AlwaysIncludeUserClaimsInIdToken")
.HasColumnType("INTEGER");
b.Property<bool>("AlwaysSendClientClaims")
.HasColumnType("INTEGER");
b.Property<int>("AuthorizationCodeLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("BackChannelLogoutSessionRequired")
.HasColumnType("INTEGER");
b.Property<string>("BackChannelLogoutUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<string>("ClientClaimsPrefix")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<int?>("ConsentLifetime")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<int>("DeviceCodeLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("EnableLocalLogin")
.HasColumnType("INTEGER");
b.Property<bool>("Enabled")
.HasColumnType("INTEGER");
b.Property<bool>("FrontChannelLogoutSessionRequired")
.HasColumnType("INTEGER");
b.Property<string>("FrontChannelLogoutUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<int>("IdentityTokenLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("IncludeJwtId")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LastAccessed")
.HasColumnType("TEXT");
b.Property<string>("LogoUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<bool>("NonEditable")
.HasColumnType("INTEGER");
b.Property<string>("PairWiseSubjectSalt")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ProtocolType")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<int>("RefreshTokenExpiration")
.HasColumnType("INTEGER");
b.Property<int>("RefreshTokenUsage")
.HasColumnType("INTEGER");
b.Property<bool>("RequireClientSecret")
.HasColumnType("INTEGER");
b.Property<bool>("RequireConsent")
.HasColumnType("INTEGER");
b.Property<bool>("RequirePkce")
.HasColumnType("INTEGER");
b.Property<int>("SlidingRefreshTokenLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("UpdateAccessTokenClaimsOnRefresh")
.HasColumnType("INTEGER");
b.Property<DateTime?>("Updated")
.HasColumnType("TEXT");
b.Property<string>("UserCodeType")
.HasColumnType("TEXT")
.HasMaxLength(100);
b.Property<int?>("UserSsoLifetime")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ClientId")
.IsUnique();
b.ToTable("Clients");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Origin")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(150);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientCorsOrigins");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("GrantType")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientGrantTypes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Provider")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientIdPRestrictions");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("PostLogoutRedirectUri")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientPostLogoutRedirectUris");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientProperties");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("RedirectUri")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientRedirectUris");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Scope")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientScopes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(4000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientSecrets");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("IdentityResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("IdentityResourceId");
b.ToTable("IdentityClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResource", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("INTEGER");
b.Property<bool>("Enabled")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("NonEditable")
.HasColumnType("INTEGER");
b.Property<bool>("Required")
.HasColumnType("INTEGER");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("INTEGER");
b.Property<DateTime?>("Updated")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("IdentityResources");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("IdentityResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("IdentityResourceId");
b.ToTable("IdentityProperties");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("Properties")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("Scopes")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiScope", "ApiScope")
.WithMany("UserClaims")
.HasForeignKey("ApiScopeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("Secrets")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("Claims")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("AllowedCorsOrigins")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("AllowedGrantTypes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("IdentityProviderRestrictions")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("PostLogoutRedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("Properties")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("RedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("AllowedScopes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("ClientSecrets")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.IdentityResource", "IdentityResource")
.WithMany("UserClaims")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.IdentityResource", "IdentityResource")
.WithMany("Properties")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,607 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Kyoo.Models.DatabaseMigrations
{
public partial class IS_Configuration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApiResources",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Enabled = table.Column<bool>(nullable: false),
Name = table.Column<string>(maxLength: 200, nullable: false),
DisplayName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Created = table.Column<DateTime>(nullable: false),
Updated = table.Column<DateTime>(nullable: true),
LastAccessed = table.Column<DateTime>(nullable: true),
NonEditable = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiResources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Enabled = table.Column<bool>(nullable: false),
ClientId = table.Column<string>(maxLength: 200, nullable: false),
ProtocolType = table.Column<string>(maxLength: 200, nullable: false),
RequireClientSecret = table.Column<bool>(nullable: false),
ClientName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
ClientUri = table.Column<string>(maxLength: 2000, nullable: true),
LogoUri = table.Column<string>(maxLength: 2000, nullable: true),
RequireConsent = table.Column<bool>(nullable: false),
AllowRememberConsent = table.Column<bool>(nullable: false),
AlwaysIncludeUserClaimsInIdToken = table.Column<bool>(nullable: false),
RequirePkce = table.Column<bool>(nullable: false),
AllowPlainTextPkce = table.Column<bool>(nullable: false),
AllowAccessTokensViaBrowser = table.Column<bool>(nullable: false),
FrontChannelLogoutUri = table.Column<string>(maxLength: 2000, nullable: true),
FrontChannelLogoutSessionRequired = table.Column<bool>(nullable: false),
BackChannelLogoutUri = table.Column<string>(maxLength: 2000, nullable: true),
BackChannelLogoutSessionRequired = table.Column<bool>(nullable: false),
AllowOfflineAccess = table.Column<bool>(nullable: false),
IdentityTokenLifetime = table.Column<int>(nullable: false),
AccessTokenLifetime = table.Column<int>(nullable: false),
AuthorizationCodeLifetime = table.Column<int>(nullable: false),
ConsentLifetime = table.Column<int>(nullable: true),
AbsoluteRefreshTokenLifetime = table.Column<int>(nullable: false),
SlidingRefreshTokenLifetime = table.Column<int>(nullable: false),
RefreshTokenUsage = table.Column<int>(nullable: false),
UpdateAccessTokenClaimsOnRefresh = table.Column<bool>(nullable: false),
RefreshTokenExpiration = table.Column<int>(nullable: false),
AccessTokenType = table.Column<int>(nullable: false),
EnableLocalLogin = table.Column<bool>(nullable: false),
IncludeJwtId = table.Column<bool>(nullable: false),
AlwaysSendClientClaims = table.Column<bool>(nullable: false),
ClientClaimsPrefix = table.Column<string>(maxLength: 200, nullable: true),
PairWiseSubjectSalt = table.Column<string>(maxLength: 200, nullable: true),
Created = table.Column<DateTime>(nullable: false),
Updated = table.Column<DateTime>(nullable: true),
LastAccessed = table.Column<DateTime>(nullable: true),
UserSsoLifetime = table.Column<int>(nullable: true),
UserCodeType = table.Column<string>(maxLength: 100, nullable: true),
DeviceCodeLifetime = table.Column<int>(nullable: false),
NonEditable = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityResources",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Enabled = table.Column<bool>(nullable: false),
Name = table.Column<string>(maxLength: 200, nullable: false),
DisplayName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Required = table.Column<bool>(nullable: false),
Emphasize = table.Column<bool>(nullable: false),
ShowInDiscoveryDocument = table.Column<bool>(nullable: false),
Created = table.Column<DateTime>(nullable: false),
Updated = table.Column<DateTime>(nullable: true),
NonEditable = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityResources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ApiClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(maxLength: 200, nullable: false),
ApiResourceId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiClaims", x => x.Id);
table.ForeignKey(
name: "FK_ApiClaims_ApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApiProperties",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Key = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 2000, nullable: false),
ApiResourceId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiProperties", x => x.Id);
table.ForeignKey(
name: "FK_ApiProperties_ApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApiScopes",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(maxLength: 200, nullable: false),
DisplayName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Required = table.Column<bool>(nullable: false),
Emphasize = table.Column<bool>(nullable: false),
ShowInDiscoveryDocument = table.Column<bool>(nullable: false),
ApiResourceId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiScopes", x => x.Id);
table.ForeignKey(
name: "FK_ApiScopes_ApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApiSecrets",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Value = table.Column<string>(maxLength: 4000, nullable: false),
Expiration = table.Column<DateTime>(nullable: true),
Type = table.Column<string>(maxLength: 250, nullable: false),
Created = table.Column<DateTime>(nullable: false),
ApiResourceId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiSecrets", x => x.Id);
table.ForeignKey(
name: "FK_ApiSecrets_ApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 250, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientClaims", x => x.Id);
table.ForeignKey(
name: "FK_ClientClaims_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientCorsOrigins",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Origin = table.Column<string>(maxLength: 150, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientCorsOrigins", x => x.Id);
table.ForeignKey(
name: "FK_ClientCorsOrigins_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientGrantTypes",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GrantType = table.Column<string>(maxLength: 250, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientGrantTypes", x => x.Id);
table.ForeignKey(
name: "FK_ClientGrantTypes_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientIdPRestrictions",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Provider = table.Column<string>(maxLength: 200, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientIdPRestrictions", x => x.Id);
table.ForeignKey(
name: "FK_ClientIdPRestrictions_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientPostLogoutRedirectUris",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PostLogoutRedirectUri = table.Column<string>(maxLength: 2000, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientPostLogoutRedirectUris", x => x.Id);
table.ForeignKey(
name: "FK_ClientPostLogoutRedirectUris_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientProperties",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Key = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 2000, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientProperties", x => x.Id);
table.ForeignKey(
name: "FK_ClientProperties_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientRedirectUris",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
RedirectUri = table.Column<string>(maxLength: 2000, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientRedirectUris", x => x.Id);
table.ForeignKey(
name: "FK_ClientRedirectUris_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientScopes",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Scope = table.Column<string>(maxLength: 200, nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientScopes", x => x.Id);
table.ForeignKey(
name: "FK_ClientScopes_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientSecrets",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Description = table.Column<string>(maxLength: 2000, nullable: true),
Value = table.Column<string>(maxLength: 4000, nullable: false),
Expiration = table.Column<DateTime>(nullable: true),
Type = table.Column<string>(maxLength: 250, nullable: false),
Created = table.Column<DateTime>(nullable: false),
ClientId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientSecrets", x => x.Id);
table.ForeignKey(
name: "FK_ClientSecrets_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(maxLength: 200, nullable: false),
IdentityResourceId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityClaims", x => x.Id);
table.ForeignKey(
name: "FK_IdentityClaims_IdentityResources_IdentityResourceId",
column: x => x.IdentityResourceId,
principalTable: "IdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityProperties",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Key = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 2000, nullable: false),
IdentityResourceId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityProperties", x => x.Id);
table.ForeignKey(
name: "FK_IdentityProperties_IdentityResources_IdentityResourceId",
column: x => x.IdentityResourceId,
principalTable: "IdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApiScopeClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(maxLength: 200, nullable: false),
ApiScopeId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiScopeClaims", x => x.Id);
table.ForeignKey(
name: "FK_ApiScopeClaims_ApiScopes_ApiScopeId",
column: x => x.ApiScopeId,
principalTable: "ApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ApiClaims_ApiResourceId",
table: "ApiClaims",
column: "ApiResourceId");
migrationBuilder.CreateIndex(
name: "IX_ApiProperties_ApiResourceId",
table: "ApiProperties",
column: "ApiResourceId");
migrationBuilder.CreateIndex(
name: "IX_ApiResources_Name",
table: "ApiResources",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ApiScopeClaims_ApiScopeId",
table: "ApiScopeClaims",
column: "ApiScopeId");
migrationBuilder.CreateIndex(
name: "IX_ApiScopes_ApiResourceId",
table: "ApiScopes",
column: "ApiResourceId");
migrationBuilder.CreateIndex(
name: "IX_ApiScopes_Name",
table: "ApiScopes",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ApiSecrets_ApiResourceId",
table: "ApiSecrets",
column: "ApiResourceId");
migrationBuilder.CreateIndex(
name: "IX_ClientClaims_ClientId",
table: "ClientClaims",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientCorsOrigins_ClientId",
table: "ClientCorsOrigins",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientGrantTypes_ClientId",
table: "ClientGrantTypes",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientIdPRestrictions_ClientId",
table: "ClientIdPRestrictions",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientPostLogoutRedirectUris_ClientId",
table: "ClientPostLogoutRedirectUris",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientProperties_ClientId",
table: "ClientProperties",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientRedirectUris_ClientId",
table: "ClientRedirectUris",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Clients_ClientId",
table: "Clients",
column: "ClientId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ClientScopes_ClientId",
table: "ClientScopes",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientSecrets_ClientId",
table: "ClientSecrets",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_IdentityClaims_IdentityResourceId",
table: "IdentityClaims",
column: "IdentityResourceId");
migrationBuilder.CreateIndex(
name: "IX_IdentityProperties_IdentityResourceId",
table: "IdentityProperties",
column: "IdentityResourceId");
migrationBuilder.CreateIndex(
name: "IX_IdentityResources_Name",
table: "IdentityResources",
column: "Name",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApiClaims");
migrationBuilder.DropTable(
name: "ApiProperties");
migrationBuilder.DropTable(
name: "ApiScopeClaims");
migrationBuilder.DropTable(
name: "ApiSecrets");
migrationBuilder.DropTable(
name: "ClientClaims");
migrationBuilder.DropTable(
name: "ClientCorsOrigins");
migrationBuilder.DropTable(
name: "ClientGrantTypes");
migrationBuilder.DropTable(
name: "ClientIdPRestrictions");
migrationBuilder.DropTable(
name: "ClientPostLogoutRedirectUris");
migrationBuilder.DropTable(
name: "ClientProperties");
migrationBuilder.DropTable(
name: "ClientRedirectUris");
migrationBuilder.DropTable(
name: "ClientScopes");
migrationBuilder.DropTable(
name: "ClientSecrets");
migrationBuilder.DropTable(
name: "IdentityClaims");
migrationBuilder.DropTable(
name: "IdentityProperties");
migrationBuilder.DropTable(
name: "ApiScopes");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "IdentityResources");
migrationBuilder.DropTable(
name: "ApiResources");
}
}
}

View File

@ -0,0 +1,811 @@
// <auto-generated />
using System;
using IdentityServer4.EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations
{
[DbContext(typeof(ConfigurationDbContext))]
partial class ConfigurationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResource", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Enabled")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LastAccessed")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("NonEditable")
.HasColumnType("INTEGER");
b.Property<DateTime?>("Updated")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("ApiResources");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.ToTable("ApiClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.ToTable("ApiProperties");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Required")
.HasColumnType("INTEGER");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("ApiScopes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiScopeId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ApiScopeId");
b.ToTable("ApiScopeClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ApiResourceId")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<DateTime?>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(4000);
b.HasKey("Id");
b.HasIndex("ApiResourceId");
b.ToTable("ApiSecrets");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AbsoluteRefreshTokenLifetime")
.HasColumnType("INTEGER");
b.Property<int>("AccessTokenLifetime")
.HasColumnType("INTEGER");
b.Property<int>("AccessTokenType")
.HasColumnType("INTEGER");
b.Property<bool>("AllowAccessTokensViaBrowser")
.HasColumnType("INTEGER");
b.Property<bool>("AllowOfflineAccess")
.HasColumnType("INTEGER");
b.Property<bool>("AllowPlainTextPkce")
.HasColumnType("INTEGER");
b.Property<bool>("AllowRememberConsent")
.HasColumnType("INTEGER");
b.Property<bool>("AlwaysIncludeUserClaimsInIdToken")
.HasColumnType("INTEGER");
b.Property<bool>("AlwaysSendClientClaims")
.HasColumnType("INTEGER");
b.Property<int>("AuthorizationCodeLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("BackChannelLogoutSessionRequired")
.HasColumnType("INTEGER");
b.Property<string>("BackChannelLogoutUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<string>("ClientClaimsPrefix")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<int?>("ConsentLifetime")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<int>("DeviceCodeLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("EnableLocalLogin")
.HasColumnType("INTEGER");
b.Property<bool>("Enabled")
.HasColumnType("INTEGER");
b.Property<bool>("FrontChannelLogoutSessionRequired")
.HasColumnType("INTEGER");
b.Property<string>("FrontChannelLogoutUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<int>("IdentityTokenLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("IncludeJwtId")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LastAccessed")
.HasColumnType("TEXT");
b.Property<string>("LogoUri")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<bool>("NonEditable")
.HasColumnType("INTEGER");
b.Property<string>("PairWiseSubjectSalt")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ProtocolType")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<int>("RefreshTokenExpiration")
.HasColumnType("INTEGER");
b.Property<int>("RefreshTokenUsage")
.HasColumnType("INTEGER");
b.Property<bool>("RequireClientSecret")
.HasColumnType("INTEGER");
b.Property<bool>("RequireConsent")
.HasColumnType("INTEGER");
b.Property<bool>("RequirePkce")
.HasColumnType("INTEGER");
b.Property<int>("SlidingRefreshTokenLifetime")
.HasColumnType("INTEGER");
b.Property<bool>("UpdateAccessTokenClaimsOnRefresh")
.HasColumnType("INTEGER");
b.Property<DateTime?>("Updated")
.HasColumnType("TEXT");
b.Property<string>("UserCodeType")
.HasColumnType("TEXT")
.HasMaxLength(100);
b.Property<int?>("UserSsoLifetime")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ClientId")
.IsUnique();
b.ToTable("Clients");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Origin")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(150);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientCorsOrigins");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("GrantType")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientGrantTypes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Provider")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientIdPRestrictions");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("PostLogoutRedirectUri")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientPostLogoutRedirectUris");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientProperties");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("RedirectUri")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientRedirectUris");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<string>("Scope")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientScopes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ClientId")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(4000);
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientSecrets");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("IdentityResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("IdentityResourceId");
b.ToTable("IdentityClaims");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResource", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("INTEGER");
b.Property<bool>("Enabled")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<bool>("NonEditable")
.HasColumnType("INTEGER");
b.Property<bool>("Required")
.HasColumnType("INTEGER");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("INTEGER");
b.Property<DateTime?>("Updated")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("IdentityResources");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("IdentityResourceId")
.HasColumnType("INTEGER");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(2000);
b.HasKey("Id");
b.HasIndex("IdentityResourceId");
b.ToTable("IdentityProperties");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("Properties")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("Scopes")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiScope", "ApiScope")
.WithMany("UserClaims")
.HasForeignKey("ApiScopeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.ApiResource", "ApiResource")
.WithMany("Secrets")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("Claims")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("AllowedCorsOrigins")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("AllowedGrantTypes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("IdentityProviderRestrictions")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("PostLogoutRedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("Properties")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("RedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("AllowedScopes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.Client", "Client")
.WithMany("ClientSecrets")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.IdentityResource", "IdentityResource")
.WithMany("UserClaims")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b =>
{
b.HasOne("IdentityServer4.EntityFramework.Entities.IdentityResource", "IdentityResource")
.WithMany("Properties")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,105 @@
// <auto-generated />
using System;
using IdentityServer4.EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations.IdentityPeristant
{
[DbContext(typeof(PersistedGrantDbContext))]
[Migration("20200303214150_IS_Configuration")]
partial class IS_Configuration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.DeviceFlowCodes", b =>
{
b.Property<string>("UserCode")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<DateTime>("CreationTime")
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50000);
b.Property<string>("DeviceCode")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<DateTime?>("Expiration")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SubjectId")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("UserCode");
b.HasIndex("DeviceCode")
.IsUnique();
b.HasIndex("Expiration");
b.ToTable("DeviceCodes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.PersistedGrant", b =>
{
b.Property<string>("Key")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<DateTime>("CreationTime")
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50000);
b.Property<DateTime?>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("SubjectId")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50);
b.HasKey("Key");
b.HasIndex("Expiration");
b.HasIndex("SubjectId", "ClientId", "Type");
b.ToTable("PersistedGrants");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Kyoo.Models.DatabaseMigrations.IdentityPeristant
{
public partial class IS_Configuration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DeviceCodes",
columns: table => new
{
UserCode = table.Column<string>(maxLength: 200, nullable: false),
DeviceCode = table.Column<string>(maxLength: 200, nullable: false),
SubjectId = table.Column<string>(maxLength: 200, nullable: true),
ClientId = table.Column<string>(maxLength: 200, nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
Expiration = table.Column<DateTime>(nullable: false),
Data = table.Column<string>(maxLength: 50000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceCodes", x => x.UserCode);
});
migrationBuilder.CreateTable(
name: "PersistedGrants",
columns: table => new
{
Key = table.Column<string>(maxLength: 200, nullable: false),
Type = table.Column<string>(maxLength: 50, nullable: false),
SubjectId = table.Column<string>(maxLength: 200, nullable: true),
ClientId = table.Column<string>(maxLength: 200, nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
Expiration = table.Column<DateTime>(nullable: true),
Data = table.Column<string>(maxLength: 50000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PersistedGrants", x => x.Key);
});
migrationBuilder.CreateIndex(
name: "IX_DeviceCodes_DeviceCode",
table: "DeviceCodes",
column: "DeviceCode",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DeviceCodes_Expiration",
table: "DeviceCodes",
column: "Expiration");
migrationBuilder.CreateIndex(
name: "IX_PersistedGrants_Expiration",
table: "PersistedGrants",
column: "Expiration");
migrationBuilder.CreateIndex(
name: "IX_PersistedGrants_SubjectId_ClientId_Type",
table: "PersistedGrants",
columns: new[] { "SubjectId", "ClientId", "Type" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceCodes");
migrationBuilder.DropTable(
name: "PersistedGrants");
}
}
}

View File

@ -0,0 +1,103 @@
// <auto-generated />
using System;
using IdentityServer4.EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations.IdentityPeristant
{
[DbContext(typeof(PersistedGrantDbContext))]
partial class PersistedGrantDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.DeviceFlowCodes", b =>
{
b.Property<string>("UserCode")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<DateTime>("CreationTime")
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50000);
b.Property<string>("DeviceCode")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<DateTime?>("Expiration")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SubjectId")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.HasKey("UserCode");
b.HasIndex("DeviceCode")
.IsUnique();
b.HasIndex("Expiration");
b.ToTable("DeviceCodes");
});
modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.PersistedGrant", b =>
{
b.Property<string>("Key")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<DateTime>("CreationTime")
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50000);
b.Property<DateTime?>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("SubjectId")
.HasColumnType("TEXT")
.HasMaxLength(200);
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50);
b.HasKey("Key");
b.HasIndex("Expiration");
b.HasIndex("SubjectId", "ClientId", "Type");
b.ToTable("PersistedGrants");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,496 @@
// <auto-generated />
using System;
using Kyoo;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20200303213358_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("Kyoo.Models.Collection", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Poster")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Collections");
});
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("CollectionID")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("CollectionID");
b.HasIndex("ShowID");
b.ToTable("CollectionLinks");
});
modelBuilder.Entity("Kyoo.Models.Episode", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AbsoluteNumber")
.HasColumnType("INTEGER");
b.Property<long>("EpisodeNumber")
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("TEXT");
b.Property<long>("Runtime")
.HasColumnType("INTEGER");
b.Property<long?>("SeasonID")
.HasColumnType("INTEGER");
b.Property<long>("SeasonNumber")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("SeasonID");
b.HasIndex("ShowID");
b.ToTable("Episodes");
});
modelBuilder.Entity("Kyoo.Models.Genre", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Genres");
});
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
{
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<long>("GenreID")
.HasColumnType("INTEGER");
b.HasKey("ShowID", "GenreID");
b.HasIndex("GenreID");
b.ToTable("GenreLinks");
});
modelBuilder.Entity("Kyoo.Models.Library", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Paths")
.HasColumnType("TEXT");
b.Property<string>("Providers")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Libraries");
});
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("CollectionID")
.HasColumnType("INTEGER");
b.Property<long>("LibraryID")
.HasColumnType("INTEGER");
b.Property<long?>("ShowID")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("CollectionID");
b.HasIndex("LibraryID");
b.HasIndex("ShowID");
b.ToTable("LibraryLinks");
});
modelBuilder.Entity("Kyoo.Models.People", b =>
{
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Slug");
b.ToTable("Peoples");
});
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("PeopleID")
.HasColumnType("TEXT");
b.Property<string>("Role")
.HasColumnType("TEXT");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("PeopleID");
b.HasIndex("ShowID");
b.ToTable("PeopleLinks");
});
modelBuilder.Entity("Kyoo.Models.Season", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<long>("SeasonNumber")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<long?>("Year")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("ShowID");
b.ToTable("Seasons");
});
modelBuilder.Entity("Kyoo.Models.Show", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Aliases")
.HasColumnType("TEXT");
b.Property<long?>("EndYear")
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgBackdrop")
.HasColumnType("TEXT");
b.Property<string>("ImgLogo")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("ImgThumb")
.HasColumnType("TEXT");
b.Property<bool>("IsMovie")
.HasColumnType("INTEGER");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.Property<long?>("StartYear")
.HasColumnType("INTEGER");
b.Property<int?>("Status")
.HasColumnType("INTEGER");
b.Property<long?>("StudioID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<string>("TrailerUrl")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("StudioID");
b.ToTable("Shows");
});
modelBuilder.Entity("Kyoo.Models.Studio", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Studios");
});
modelBuilder.Entity("Kyoo.Models.Track", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Codec")
.HasColumnType("TEXT");
b.Property<long>("EpisodeID")
.HasColumnType("INTEGER");
b.Property<bool>("IsDefault")
.HasColumnType("INTEGER");
b.Property<bool>("IsExternal")
.HasColumnType("INTEGER");
b.Property<bool>("IsForced")
.HasColumnType("INTEGER");
b.Property<string>("Language")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("EpisodeID");
b.ToTable("Tracks");
});
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
{
b.HasOne("Kyoo.Models.Collection", "Collection")
.WithMany()
.HasForeignKey("CollectionID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany()
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Episode", b =>
{
b.HasOne("Kyoo.Models.Season", "Season")
.WithMany("Episodes")
.HasForeignKey("SeasonID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("Episodes")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
{
b.HasOne("Kyoo.Models.Genre", "Genre")
.WithMany()
.HasForeignKey("GenreID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("GenreLinks")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
{
b.HasOne("Kyoo.Models.Collection", "Collection")
.WithMany()
.HasForeignKey("CollectionID");
b.HasOne("Kyoo.Models.Library", "Library")
.WithMany()
.HasForeignKey("LibraryID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany()
.HasForeignKey("ShowID");
});
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
{
b.HasOne("Kyoo.Models.People", "People")
.WithMany("Roles")
.HasForeignKey("PeopleID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("People")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Season", b =>
{
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("Seasons")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Show", b =>
{
b.HasOne("Kyoo.Models.Studio", "Studio")
.WithMany()
.HasForeignKey("StudioID");
});
modelBuilder.Entity("Kyoo.Models.Track", b =>
{
b.HasOne("Kyoo.Models.Episode", "Episode")
.WithMany("Tracks")
.HasForeignKey("EpisodeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,426 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Kyoo.Models.DatabaseMigrations
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Collections",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Slug = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true),
Poster = table.Column<string>(nullable: true),
Overview = table.Column<string>(nullable: true),
ImgPrimary = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Collections", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Genres",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Slug = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Genres", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Libraries",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Slug = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true),
Paths = table.Column<string>(nullable: true),
Providers = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Libraries", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Peoples",
columns: table => new
{
Slug = table.Column<string>(nullable: false),
Name = table.Column<string>(nullable: true),
ImgPrimary = table.Column<string>(nullable: true),
ExternalIDs = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Peoples", x => x.Slug);
});
migrationBuilder.CreateTable(
name: "Studios",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Slug = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Studios", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Shows",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Slug = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
Aliases = table.Column<string>(nullable: true),
Path = table.Column<string>(nullable: true),
Overview = table.Column<string>(nullable: true),
Status = table.Column<int>(nullable: true),
TrailerUrl = table.Column<string>(nullable: true),
StartYear = table.Column<long>(nullable: true),
EndYear = table.Column<long>(nullable: true),
ImgPrimary = table.Column<string>(nullable: true),
ImgThumb = table.Column<string>(nullable: true),
ImgLogo = table.Column<string>(nullable: true),
ImgBackdrop = table.Column<string>(nullable: true),
ExternalIDs = table.Column<string>(nullable: true),
IsMovie = table.Column<bool>(nullable: false),
StudioID = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Shows", x => x.ID);
table.ForeignKey(
name: "FK_Shows_Studios_StudioID",
column: x => x.StudioID,
principalTable: "Studios",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CollectionLinks",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CollectionID = table.Column<long>(nullable: true),
ShowID = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CollectionLinks", x => x.ID);
table.ForeignKey(
name: "FK_CollectionLinks_Collections_CollectionID",
column: x => x.CollectionID,
principalTable: "Collections",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CollectionLinks_Shows_ShowID",
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GenreLinks",
columns: table => new
{
ShowID = table.Column<long>(nullable: false),
GenreID = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GenreLinks", x => new { x.ShowID, x.GenreID });
table.ForeignKey(
name: "FK_GenreLinks_Genres_GenreID",
column: x => x.GenreID,
principalTable: "Genres",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GenreLinks_Shows_ShowID",
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "LibraryLinks",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
LibraryID = table.Column<long>(nullable: false),
ShowID = table.Column<long>(nullable: true),
CollectionID = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_LibraryLinks", x => x.ID);
table.ForeignKey(
name: "FK_LibraryLinks_Collections_CollectionID",
column: x => x.CollectionID,
principalTable: "Collections",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_LibraryLinks_Libraries_LibraryID",
column: x => x.LibraryID,
principalTable: "Libraries",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_LibraryLinks_Shows_ShowID",
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "PeopleLinks",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PeopleID = table.Column<string>(nullable: true),
ShowID = table.Column<long>(nullable: false),
Role = table.Column<string>(nullable: true),
Type = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PeopleLinks", x => x.ID);
table.ForeignKey(
name: "FK_PeopleLinks_Peoples_PeopleID",
column: x => x.PeopleID,
principalTable: "Peoples",
principalColumn: "Slug",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_PeopleLinks_Shows_ShowID",
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Seasons",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ShowID = table.Column<long>(nullable: false),
SeasonNumber = table.Column<long>(nullable: false),
Title = table.Column<string>(nullable: true),
Overview = table.Column<string>(nullable: true),
Year = table.Column<long>(nullable: true),
ImgPrimary = table.Column<string>(nullable: true),
ExternalIDs = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Seasons", x => x.ID);
table.ForeignKey(
name: "FK_Seasons_Shows_ShowID",
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Episodes",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ShowID = table.Column<long>(nullable: false),
SeasonID = table.Column<long>(nullable: true),
SeasonNumber = table.Column<long>(nullable: false),
EpisodeNumber = table.Column<long>(nullable: false),
AbsoluteNumber = table.Column<long>(nullable: false),
Path = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
Overview = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: true),
Runtime = table.Column<long>(nullable: false),
ImgPrimary = table.Column<string>(nullable: true),
ExternalIDs = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Episodes", x => x.ID);
table.ForeignKey(
name: "FK_Episodes_Seasons_SeasonID",
column: x => x.SeasonID,
principalTable: "Seasons",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Episodes_Shows_ShowID",
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Tracks",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Title = table.Column<string>(nullable: true),
Language = table.Column<string>(nullable: true),
Codec = table.Column<string>(nullable: true),
Path = table.Column<string>(nullable: true),
Type = table.Column<int>(nullable: false),
EpisodeID = table.Column<long>(nullable: false),
IsDefault = table.Column<bool>(nullable: false),
IsForced = table.Column<bool>(nullable: false),
IsExternal = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tracks", x => x.ID);
table.ForeignKey(
name: "FK_Tracks_Episodes_EpisodeID",
column: x => x.EpisodeID,
principalTable: "Episodes",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CollectionLinks_CollectionID",
table: "CollectionLinks",
column: "CollectionID");
migrationBuilder.CreateIndex(
name: "IX_CollectionLinks_ShowID",
table: "CollectionLinks",
column: "ShowID");
migrationBuilder.CreateIndex(
name: "IX_Episodes_SeasonID",
table: "Episodes",
column: "SeasonID");
migrationBuilder.CreateIndex(
name: "IX_Episodes_ShowID",
table: "Episodes",
column: "ShowID");
migrationBuilder.CreateIndex(
name: "IX_GenreLinks_GenreID",
table: "GenreLinks",
column: "GenreID");
migrationBuilder.CreateIndex(
name: "IX_LibraryLinks_CollectionID",
table: "LibraryLinks",
column: "CollectionID");
migrationBuilder.CreateIndex(
name: "IX_LibraryLinks_LibraryID",
table: "LibraryLinks",
column: "LibraryID");
migrationBuilder.CreateIndex(
name: "IX_LibraryLinks_ShowID",
table: "LibraryLinks",
column: "ShowID");
migrationBuilder.CreateIndex(
name: "IX_PeopleLinks_PeopleID",
table: "PeopleLinks",
column: "PeopleID");
migrationBuilder.CreateIndex(
name: "IX_PeopleLinks_ShowID",
table: "PeopleLinks",
column: "ShowID");
migrationBuilder.CreateIndex(
name: "IX_Seasons_ShowID",
table: "Seasons",
column: "ShowID");
migrationBuilder.CreateIndex(
name: "IX_Shows_StudioID",
table: "Shows",
column: "StudioID");
migrationBuilder.CreateIndex(
name: "IX_Tracks_EpisodeID",
table: "Tracks",
column: "EpisodeID");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CollectionLinks");
migrationBuilder.DropTable(
name: "GenreLinks");
migrationBuilder.DropTable(
name: "LibraryLinks");
migrationBuilder.DropTable(
name: "PeopleLinks");
migrationBuilder.DropTable(
name: "Tracks");
migrationBuilder.DropTable(
name: "Genres");
migrationBuilder.DropTable(
name: "Collections");
migrationBuilder.DropTable(
name: "Libraries");
migrationBuilder.DropTable(
name: "Peoples");
migrationBuilder.DropTable(
name: "Episodes");
migrationBuilder.DropTable(
name: "Seasons");
migrationBuilder.DropTable(
name: "Shows");
migrationBuilder.DropTable(
name: "Studios");
}
}
}

View File

@ -0,0 +1,554 @@
// <auto-generated />
using System;
using Kyoo;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations.Internal
{
[DbContext(typeof(DatabaseContext))]
[Migration("20200306000057_Adding accounts")]
partial class Addingaccounts
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("Kyoo.Models.Account", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<string>("NormalizedEmail")
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasColumnType("TEXT");
b.Property<string>("OTAC")
.HasColumnType("TEXT");
b.Property<DateTime?>("OTACExpires")
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Accounts");
});
modelBuilder.Entity("Kyoo.Models.Collection", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Poster")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Collections");
});
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("CollectionID")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("CollectionID");
b.HasIndex("ShowID");
b.ToTable("CollectionLinks");
});
modelBuilder.Entity("Kyoo.Models.Episode", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AbsoluteNumber")
.HasColumnType("INTEGER");
b.Property<long>("EpisodeNumber")
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("TEXT");
b.Property<long>("Runtime")
.HasColumnType("INTEGER");
b.Property<long?>("SeasonID")
.HasColumnType("INTEGER");
b.Property<long>("SeasonNumber")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("SeasonID");
b.HasIndex("ShowID");
b.ToTable("Episodes");
});
modelBuilder.Entity("Kyoo.Models.Genre", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Genres");
});
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
{
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<long>("GenreID")
.HasColumnType("INTEGER");
b.HasKey("ShowID", "GenreID");
b.HasIndex("GenreID");
b.ToTable("GenreLinks");
});
modelBuilder.Entity("Kyoo.Models.Library", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Paths")
.HasColumnType("TEXT");
b.Property<string>("Providers")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Libraries");
});
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("CollectionID")
.HasColumnType("INTEGER");
b.Property<long>("LibraryID")
.HasColumnType("INTEGER");
b.Property<long?>("ShowID")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("CollectionID");
b.HasIndex("LibraryID");
b.HasIndex("ShowID");
b.ToTable("LibraryLinks");
});
modelBuilder.Entity("Kyoo.Models.People", b =>
{
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Slug");
b.ToTable("Peoples");
});
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("PeopleID")
.HasColumnType("TEXT");
b.Property<string>("Role")
.HasColumnType("TEXT");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("PeopleID");
b.HasIndex("ShowID");
b.ToTable("PeopleLinks");
});
modelBuilder.Entity("Kyoo.Models.Season", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<long>("SeasonNumber")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<long?>("Year")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("ShowID");
b.ToTable("Seasons");
});
modelBuilder.Entity("Kyoo.Models.Show", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Aliases")
.HasColumnType("TEXT");
b.Property<long?>("EndYear")
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgBackdrop")
.HasColumnType("TEXT");
b.Property<string>("ImgLogo")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("ImgThumb")
.HasColumnType("TEXT");
b.Property<bool>("IsMovie")
.HasColumnType("INTEGER");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.Property<long?>("StartYear")
.HasColumnType("INTEGER");
b.Property<int?>("Status")
.HasColumnType("INTEGER");
b.Property<long?>("StudioID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<string>("TrailerUrl")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("StudioID");
b.ToTable("Shows");
});
modelBuilder.Entity("Kyoo.Models.Studio", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Studios");
});
modelBuilder.Entity("Kyoo.Models.Track", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Codec")
.HasColumnType("TEXT");
b.Property<long>("EpisodeID")
.HasColumnType("INTEGER");
b.Property<bool>("IsDefault")
.HasColumnType("INTEGER");
b.Property<bool>("IsExternal")
.HasColumnType("INTEGER");
b.Property<bool>("IsForced")
.HasColumnType("INTEGER");
b.Property<string>("Language")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("EpisodeID");
b.ToTable("Tracks");
});
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
{
b.HasOne("Kyoo.Models.Collection", "Collection")
.WithMany()
.HasForeignKey("CollectionID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany()
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Episode", b =>
{
b.HasOne("Kyoo.Models.Season", "Season")
.WithMany("Episodes")
.HasForeignKey("SeasonID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("Episodes")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
{
b.HasOne("Kyoo.Models.Genre", "Genre")
.WithMany()
.HasForeignKey("GenreID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("GenreLinks")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
{
b.HasOne("Kyoo.Models.Collection", "Collection")
.WithMany()
.HasForeignKey("CollectionID");
b.HasOne("Kyoo.Models.Library", "Library")
.WithMany()
.HasForeignKey("LibraryID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany()
.HasForeignKey("ShowID");
});
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
{
b.HasOne("Kyoo.Models.People", "People")
.WithMany("Roles")
.HasForeignKey("PeopleID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("People")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Season", b =>
{
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("Seasons")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Show", b =>
{
b.HasOne("Kyoo.Models.Studio", "Studio")
.WithMany()
.HasForeignKey("StudioID");
});
modelBuilder.Entity("Kyoo.Models.Track", b =>
{
b.HasOne("Kyoo.Models.Episode", "Episode")
.WithMany("Tracks")
.HasForeignKey("EpisodeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,44 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Kyoo.Models.DatabaseMigrations.Internal
{
public partial class Addingaccounts : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserName = table.Column<string>(nullable: true),
NormalizedUserName = table.Column<string>(nullable: true),
Email = table.Column<string>(nullable: true),
NormalizedEmail = table.Column<string>(nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
OTAC = table.Column<string>(nullable: true),
OTACExpires = table.Column<DateTime>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accounts");
}
}
}

View File

@ -0,0 +1,552 @@
// <auto-generated />
using System;
using Kyoo;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.Models.DatabaseMigrations
{
[DbContext(typeof(DatabaseContext))]
partial class DatabaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2");
modelBuilder.Entity("Kyoo.Models.Account", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<string>("NormalizedEmail")
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasColumnType("TEXT");
b.Property<string>("OTAC")
.HasColumnType("TEXT");
b.Property<DateTime?>("OTACExpires")
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Accounts");
});
modelBuilder.Entity("Kyoo.Models.Collection", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Poster")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Collections");
});
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("CollectionID")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("CollectionID");
b.HasIndex("ShowID");
b.ToTable("CollectionLinks");
});
modelBuilder.Entity("Kyoo.Models.Episode", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AbsoluteNumber")
.HasColumnType("INTEGER");
b.Property<long>("EpisodeNumber")
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<DateTime?>("ReleaseDate")
.HasColumnType("TEXT");
b.Property<long>("Runtime")
.HasColumnType("INTEGER");
b.Property<long?>("SeasonID")
.HasColumnType("INTEGER");
b.Property<long>("SeasonNumber")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("SeasonID");
b.HasIndex("ShowID");
b.ToTable("Episodes");
});
modelBuilder.Entity("Kyoo.Models.Genre", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Genres");
});
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
{
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<long>("GenreID")
.HasColumnType("INTEGER");
b.HasKey("ShowID", "GenreID");
b.HasIndex("GenreID");
b.ToTable("GenreLinks");
});
modelBuilder.Entity("Kyoo.Models.Library", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Paths")
.HasColumnType("TEXT");
b.Property<string>("Providers")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Libraries");
});
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("CollectionID")
.HasColumnType("INTEGER");
b.Property<long>("LibraryID")
.HasColumnType("INTEGER");
b.Property<long?>("ShowID")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("CollectionID");
b.HasIndex("LibraryID");
b.HasIndex("ShowID");
b.ToTable("LibraryLinks");
});
modelBuilder.Entity("Kyoo.Models.People", b =>
{
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Slug");
b.ToTable("Peoples");
});
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("PeopleID")
.HasColumnType("TEXT");
b.Property<string>("Role")
.HasColumnType("TEXT");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("PeopleID");
b.HasIndex("ShowID");
b.ToTable("PeopleLinks");
});
modelBuilder.Entity("Kyoo.Models.Season", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<long>("SeasonNumber")
.HasColumnType("INTEGER");
b.Property<long>("ShowID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<long?>("Year")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("ShowID");
b.ToTable("Seasons");
});
modelBuilder.Entity("Kyoo.Models.Show", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Aliases")
.HasColumnType("TEXT");
b.Property<long?>("EndYear")
.HasColumnType("INTEGER");
b.Property<string>("ExternalIDs")
.HasColumnType("TEXT");
b.Property<string>("ImgBackdrop")
.HasColumnType("TEXT");
b.Property<string>("ImgLogo")
.HasColumnType("TEXT");
b.Property<string>("ImgPrimary")
.HasColumnType("TEXT");
b.Property<string>("ImgThumb")
.HasColumnType("TEXT");
b.Property<bool>("IsMovie")
.HasColumnType("INTEGER");
b.Property<string>("Overview")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.Property<long?>("StartYear")
.HasColumnType("INTEGER");
b.Property<int?>("Status")
.HasColumnType("INTEGER");
b.Property<long?>("StudioID")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<string>("TrailerUrl")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("StudioID");
b.ToTable("Shows");
});
modelBuilder.Entity("Kyoo.Models.Studio", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Slug")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Studios");
});
modelBuilder.Entity("Kyoo.Models.Track", b =>
{
b.Property<long>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Codec")
.HasColumnType("TEXT");
b.Property<long>("EpisodeID")
.HasColumnType("INTEGER");
b.Property<bool>("IsDefault")
.HasColumnType("INTEGER");
b.Property<bool>("IsExternal")
.HasColumnType("INTEGER");
b.Property<bool>("IsForced")
.HasColumnType("INTEGER");
b.Property<string>("Language")
.HasColumnType("TEXT");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("EpisodeID");
b.ToTable("Tracks");
});
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
{
b.HasOne("Kyoo.Models.Collection", "Collection")
.WithMany()
.HasForeignKey("CollectionID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany()
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Episode", b =>
{
b.HasOne("Kyoo.Models.Season", "Season")
.WithMany("Episodes")
.HasForeignKey("SeasonID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("Episodes")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
{
b.HasOne("Kyoo.Models.Genre", "Genre")
.WithMany()
.HasForeignKey("GenreID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("GenreLinks")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
{
b.HasOne("Kyoo.Models.Collection", "Collection")
.WithMany()
.HasForeignKey("CollectionID");
b.HasOne("Kyoo.Models.Library", "Library")
.WithMany()
.HasForeignKey("LibraryID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany()
.HasForeignKey("ShowID");
});
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
{
b.HasOne("Kyoo.Models.People", "People")
.WithMany("Roles")
.HasForeignKey("PeopleID");
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("People")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Season", b =>
{
b.HasOne("Kyoo.Models.Show", "Show")
.WithMany("Seasons")
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Kyoo.Models.Show", b =>
{
b.HasOne("Kyoo.Models.Studio", "Studio")
.WithMany()
.HasForeignKey("StudioID");
});
modelBuilder.Entity("Kyoo.Models.Track", b =>
{
b.HasOne("Kyoo.Models.Episode", "Episode")
.WithMany("Tracks")
.HasForeignKey("EpisodeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -14,6 +14,22 @@ namespace Kyoo
new IdentityResources.Profile()
};
}
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "kyoo.webapp",
ClientSecrets = { new Secret("secret".Sha256()) },
AllowedGrantTypes = GrantTypes.Implicit,
AllowedScopes = { "kyoo.admin", "kyoo.write", "kyoo.read", "openid", "profile" },
AllowAccessTokensViaBrowser = true,
RequireConsent = false
}
};
}
public static IEnumerable<ApiResource> GetApis()
{

View File

@ -1,8 +1,6 @@
using System.Collections.Generic;
using IdentityServer4.EntityFramework.DbContexts;
using IdentityServer4.Models;
using IdentityServer4.Stores;
using System.Reflection;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
@ -35,21 +33,34 @@ namespace Kyoo
services.AddControllers().AddNewtonsoftJson();
services.AddHttpClient();
string assemblyName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
string publicUrl = Configuration.GetValue<string>("public_url");
services.AddDbContext<DatabaseContext>(options => options.UseLazyLoadingProxies()
.UseSqlite(Configuration.GetConnectionString("Database")));
services.AddIdentityServer()
services.AddIdentity<Account, IdentityRole>()
.AddEntityFrameworkStores<DatabaseContext>()
.AddDefaultTokenProviders();
services.AddIdentityServer(options =>
{
options.UserInteraction.LoginUrl = publicUrl + "/login";
options.UserInteraction.ErrorUrl = publicUrl + "/error";
options.UserInteraction.LogoutUrl = publicUrl + "/logout";
})
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = builder => builder.UseSqlite(Configuration.GetConnectionString("Database"));
options.ConfigureDbContext = builder => builder.UseSqlite(Configuration.GetConnectionString("Database"), sql => sql.MigrationsAssembly(assemblyName));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = builder => builder.UseSqlite(Configuration.GetConnectionString("Database"));
options.ConfigureDbContext = builder => builder.UseSqlite(Configuration.GetConnectionString("Database"), sql => sql.MigrationsAssembly(assemblyName));
options.EnableTokenCleanup = true;
})
.AddInMemoryIdentityResources(IdentityContext.GetIdentityResources())
.AddInMemoryApiResources(IdentityContext.GetApis());
.AddInMemoryApiResources(IdentityContext.GetApis())
.AddAspNetIdentity<Account>();
services.AddScoped<ILibraryManager, LibraryManager>();
services.AddScoped<ICrawler, Crawler>();

View File

@ -0,0 +1,41 @@
using System;
using System.Threading.Tasks;
using Kyoo.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
namespace Kyoo.Api
{
public class RegisterRequest
{
public string Email;
public string Username;
public string Password;
}
[Route("api/[controller]")]
[ApiController]
public class AccountController : Controller
{
private readonly UserManager<Account> _accountManager;
public AccountController(UserManager<Account> accountManager)
{
_accountManager = accountManager;
}
[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] RegisterRequest user)
{
if (!ModelState.IsValid)
return BadRequest(user);
Account account = new Account {UserName = user.Username, Email = user.Email};
IdentityResult result = await _accountManager.CreateAsync(account, user.Password);
if (!result.Succeeded)
return BadRequest(result.Errors);
string otac = account.GenerateOTAC(TimeSpan.FromMinutes(1));
await _accountManager.UpdateAsync(account);
return Ok(otac);
}
}
}

View File

@ -1,16 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Kyoo.Api
{
public class AuthentificationAPI : Controller
{
// [Authorize, HttpGet("/connect/authorize")]
// public async Task<IActionResult> Authorize(CancellationToken token)
// {
// //HttpContext.GetOpenIdConnectResponse()
// }
}
}

@ -1 +1 @@
Subproject commit 965c5d6a6125c5b6c3ef949d007e202ad66549df
Subproject commit af2478da584eacee6377e50dbb4c530cffd7e0b6

View File

@ -1,5 +1,6 @@
{
"server.urls": "http://0.0.0.0:5000",
"public_url": "http://localhost:5000/",
"https_port": 44300,
"Logging": {
"LogLevel": {