故事语境
提示:如果您熟悉abp + postgres + IdentityServer,可以跳过这一步,然后转到。
我目前正在尝试使用AspnetBoilerplate实现身份提供程序。
为此,我执行了以下步骤:
你可以看到我的解决方案这里。
问题
此时,我有一个功能标识提供程序,但是客户端、api资源和标识资源正在内存中运行,就像您可以使用的看见一样。
//AuthConfigurer.cs#L45
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryIdentityResources(IdentityServerConfig.GetIdentityResources())
.AddInMemoryApiResources(IdentityServerConfig.GetApiResources())
.AddInMemoryClients(IdentityServerConfig.GetClients())
.AddAbpPersistedGrants<IAbpPersistedGrantDbContext>()
.AddAbpIdentityServer<User>();所以现在我想把它放在EF里,因为我尝试了以下几点:
//SSODbContext.cs
using Microsoft.EntityFrameworkCore;
using Abp.Zero.EntityFrameworkCore;
using Coders.SSO.Authorization.Roles;
using Coders.SSO.Authorization.Users;
using Coders.SSO.MultiTenancy;
using Abp.Localization;
using Abp.IdentityServer4;
using IdentityServer4.EntityFramework.Interfaces;
using IdentityServer4.EntityFramework.Entities;
using System.Threading.Tasks;
namespace Coders.SSO.EntityFrameworkCore
{
public class SSODbContext : AbpZeroDbContext<Tenant, Role, User, SSODbContext>, IAbpPersistedGrantDbContext, IConfigurationDbContext
{
/* Define a DbSet for each entity of the application */
public DbSet<PersistedGrantEntity> PersistedGrants { get; set; }
public DbSet<Client> Clients { get; set; }
public DbSet<ApiResource> ApiResources { get; set; }
public DbSet<IdentityResource> IdentityResources { get; set; }
public SSODbContext(DbContextOptions<SSODbContext> options)
: base(options)
{
}
// add these lines to override max length of property
// we should set max length smaller than the PostgreSQL allowed size (10485760)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationLanguageText>()
.Property(p => p.Value)
.HasMaxLength(100); // any integer that is smaller than 10485760
modelBuilder.ConfigurePersistedGrantEntity();
}
public Task<int> SaveChangesAsync() => base.SaveChangesAsync();
}
}应用了一个新的迁移和更新数据库,然后我将服务调用更改如下:
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddConfigurationStore<SSODbContext>()
.AddAbpPersistedGrants<IAbpPersistedGrantDbContext>()
.AddAbpIdentityServer<User>();但是没有用,知道如何在AspNetBoilerplate上设置配置存储库吗?
发布于 2020-09-12 22:40:12
我解决了从IdentityServer存储接口中创建自己的应用程序存储库的问题,就像Scott 说在他的博客中(文章:创建自己的IdentityServer4存储库)一样。
然后我在初创公司增加了我的商店,比如:
services.AddIdentityServer()
// existing registrations
.AddClientStore<ClientStoreAppService>()
.AddCorsPolicyService<CorsPolicyService>()
.AddResourceStore<ResourcesStoreAppService>()
.AddPersistedGrantStore<PersistedGrantStoreAppService>()
.AddDeviceFlowStore<DeviceFlowStoreAppService>(); 循序渐进
发布于 2020-08-05 19:48:22
也许问题是您在这里使用了一个接口?
.AddAbpPersistedGrants<IAbpPersistedGrantDbContext>()它不应该是一种具体的类型吗?为什么你需要这个接口?
https://stackoverflow.com/questions/63239488
复制相似问题