Asp.net core IdentityServer 4:未指定授权的存储机制-使用AddInMemoryStores
我正在使用Identity Server 4,ASP.NET核心,并试图在生产环境中替换Identity Server开发人员。但是得到以下错误:Asp.net core IdentityServer 4:未指定授权的存储机制-使用AddInMemoryStores,asp.net-core,thinktecture-ident-server,identityserver4,Asp.net Core,Thinktecture Ident Server,Identityserver4,我正在使用Identity Server 4,ASP.NET核心,并试图在生产环境中替换Identity Server开发人员。但是得到以下错误: No storage mechanism for grants specified. Use the 'AddInMemoryStores' extension method to register a development version. 因此,我尝试实现本文中提到的服务: IProfileService IResourceOwnerPas
No storage mechanism for grants specified. Use the 'AddInMemoryStores' extension method to register a development version.
因此,我尝试实现本文中提到的服务:
- IProfileService
- IResourceOwnerPasswordValidator
但是我仍然得到同样的错误,问题是什么?他们曾经/正在重新编写那些API。如果要应用自定义标识,即
services.AddIdentity<AppUser, UserRole>(options => { options.User.RequireUniqueEmail = true; }).AddEntityFrameworkStores<AbcDbContext>();
评论
app.UseIdentityServer()代码>
因为我们使用的是自定义标识,而不是默认标识我已将identity Server更新为rc3,并使用了AddInMemoryPersistedGrants
。然而,它说:您正在使用持久授权存储的内存版本,这将只在内存中存储同意决策、授权代码、刷新和引用令牌。如果您在生产中使用其中任何一种,则需要切换到不同的商店实施
。我使用的是隐式流而不是刷新和引用标记。那么,在投入生产时,这将如何影响我的服务器呢?如果您不将持久授权持久化到某种形式的数据存储(SQL/Mongo),那么它们将在部署之间丢失。因此,如果您计划在生产中使用此功能,请使用支持可查询的数据存储实现IPersistedGrantStore
。您找到了吗?谢谢
public class ResourceOwnerPasswordValidator : IdentityServer4.Validation.IResourceOwnerPasswordValidator
{
public Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
{
throw new NotImplementedException();
}
}
services.AddIdentity<AppUser, UserRole>(options => { options.User.RequireUniqueEmail = true; }).AddEntityFrameworkStores<AbcDbContext>();
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)