有没有人尝试过在vNext中使用IdentityManager?
我在app.UseIdentityManager(IdentityManagerOptions)扩展方法上遇到了问题。
它并不存在。
因此,我尝试使用为UseIdentityServer (找到here)设计的扩展方法,将所有与服务器相关的方面更改为管理器。当我这样做的时候,我得到了43行的System.NullReferenceException。
任何关于如何使用扩展方法的建议都将不胜感激
发布于 2015-08-27 14:34:19
我使用的是ASP.NET5 beta6,我让它正常工作了。
尝试使用在开发上的示例存储库分支中找到的this更新的IApplicationBuilder扩展。将该方法的用途重新调整为接受IdentityManagerOptions而不是IdentityServerOptions,并将构建器编辑为UseIdentityManager
简而言之,我的扩展方法如下所示
public static class IApplicationBuilderExtensions
{
public static void UseIdentityManager(this IApplicationBuilder app, IdentityManagerOptions options)
{
app.UseOwin(addToPipeline =>
{
addToPipeline(next =>
{
var builder = new AppBuilder();
var provider = app.ApplicationServices.GetService<IDataProtectionProvider>();
builder.Properties["security.DataProtectionProvider"] =
new DataProtectionProviderDelegate(purposes =>
{
var dataProtection = provider.CreateProtector(string.Join(",", purposes));
return new DataProtectionTuple(dataProtection.Protect, dataProtection.Unprotect);
});
builder.UseIdentityManager(options);
var appFunc =
builder.Build(typeof (Func<IDictionary<string, object>, Task>)) as
Func<IDictionary<string, object>, Task>;
return appFunc;
});
});
}
}发布于 2015-06-13 23:34:15
我正在使用vNext,我注意到很多事情已经改变了,而且还将继续改变。
对于我自己的需求,我已经能够相当容易地让identity启动和运行,为了让它正常运行,我必须采取两个步骤。我所做的对你也是有效的。
在StartUp.cs中,您需要确保在ConfigureServices方法中添加以下内容:
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();除此之外,您还需要配置您的应用程序以使用标识,为此,您需要在您的Configure()方法中执行以下操作:
app.UseIdentity();https://stackoverflow.com/questions/30812349
复制相似问题