mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Removing the ASP NET Identity packet
This commit is contained in:
parent
4bdaba4643
commit
3a4ae4d5f6
@ -19,11 +19,16 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IdentityServer4" Version="3.1.2" />
|
||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.2" />
|
||||
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.2" />
|
||||
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="3.1.2" />
|
||||
<PackageReference Include="IdentityServer4.Storage" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
|
||||
<ProjectReference Include="../Kyoo.Common/Kyoo.Common.csproj" />
|
||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
|
||||
|
@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using IdentityServer4.EntityFramework.Entities;
|
||||
using IdentityServer4.EntityFramework.Extensions;
|
||||
using IdentityServer4.EntityFramework.Interfaces;
|
||||
using IdentityServer4.EntityFramework.Options;
|
||||
using Kyoo.Models;
|
||||
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
@ -11,13 +15,25 @@ using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Kyoo
|
||||
{
|
||||
public class DatabaseContext : ApiAuthorizationDbContext<User>
|
||||
public class DatabaseContext : IdentityDbContext<User>, IPersistedGrantDbContext
|
||||
{
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options, IOptions<OperationalStoreOptions> operationalStoreOptions)
|
||||
: base(options, operationalStoreOptions) { }
|
||||
private readonly IOptions<OperationalStoreOptions> _operationalStoreOptions;
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options, IOptions<OperationalStoreOptions> operationalStoreOptions)
|
||||
: base(options)
|
||||
{
|
||||
_operationalStoreOptions = operationalStoreOptions;
|
||||
}
|
||||
|
||||
public Task<int> SaveChangesAsync() => base.SaveChangesAsync();
|
||||
|
||||
public DbSet<PersistedGrant> PersistedGrants { get; set; }
|
||||
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
|
||||
|
||||
public DbSet<User> Accounts { get; set; }
|
||||
|
||||
|
||||
|
||||
public DbSet<Library> Libraries { get; set; }
|
||||
public DbSet<Collection> Collections { get; set; }
|
||||
public DbSet<Show> Shows { get; set; }
|
||||
@ -76,6 +92,7 @@ namespace Kyoo
|
||||
modelBuilder.Entity<IdentityRole>().ToTable("UserRoles");
|
||||
modelBuilder.Entity<IdentityRoleClaim<string>>().ToTable("UserRoleClaim");
|
||||
modelBuilder.Entity<IdentityUserToken<string>>().ToTable("UserToken");
|
||||
modelBuilder.ConfigurePersistedGrantContext(_operationalStoreOptions.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ using Microsoft.AspNetCore.SpaServices.AngularCli;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@ -52,7 +53,12 @@ namespace Kyoo
|
||||
string assemblyName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
|
||||
string publicUrl = _configuration.GetValue<string>("public_url");
|
||||
|
||||
services.AddDefaultIdentity<User>()
|
||||
services.AddIdentityCore<User>(o =>
|
||||
{
|
||||
o.Stores.MaxLengthForKeys = 128;
|
||||
})
|
||||
.AddSignInManager()
|
||||
.AddDefaultTokenProviders()
|
||||
.AddEntityFrameworkStores<DatabaseContext>();
|
||||
|
||||
services.AddIdentityServer(options =>
|
||||
@ -81,7 +87,13 @@ namespace Kyoo
|
||||
.AddInMemoryApiResources(IdentityContext.GetApis())
|
||||
.AddProfileService<AccountController>()
|
||||
.AddSigninKeys(_configuration);
|
||||
|
||||
|
||||
services.AddAuthentication(o =>
|
||||
{
|
||||
o.DefaultScheme = IdentityConstants.ApplicationScheme;
|
||||
o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
|
||||
})
|
||||
.AddIdentityCookies(o => { });
|
||||
services.AddAuthentication()
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user