去耦Microsoft.AspNet.Identity。* [英] Decoupling Microsoft.AspNet.Identity.*

查看:142
本文介绍了去耦Microsoft.AspNet.Identity。*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2013 RC的工作,并使用新的 Microsoft.AspNet.Identity。* 包正在测试窗体身份验证。

I am working in Visual Studio 2013 RC and am testing Forms Authentication using new Microsoft.AspNet.Identity.* packages.

我会整合这些概念(用户,角色,等等,等等),但想用我自己的域模型(波苏斯),这是在不同的装配。我也不想创建 Microsoft.AspNet.Identity的依赖。* 的DLL。

I would to integrate these concepts (Users, Roles, etc, etc) but want to use my own domain models (POCOs) which are in different assembly. I also don't want to create a dependency on Microsoft.AspNet.Identity.* dlls.

是,即使可能吗?
我发现<一个href=\"http://www.novanet.no/blog/olav-nybo/dates/2013/8/forms-authentication-using-aspnet-identity--vs-2013-$p$pview/\">this它说,这条是没有,但文章是基于preVIEW身份的包不RC版本编写的。

Is that even possible? I found this article which says it is not, but the article is written based on Preview not RC versions of identity packages.

推荐答案

我已经更新了我的样本项目,你可以在这里找到:的身份RC1样品

I have updated my sample project which you can find here: Identity RC1 sample

现在实现了一个实体框架模型,但它仍然需要对Microsoft.AspNet.Identity.EntityFramework一个参考,因为我不想重新实现所有存储类也。但样本说明如何使用您自己的POCO类模型。

It now implements an entity framework model, it still require a reference to the Microsoft.AspNet.Identity.EntityFramework as I didn't want to reimplement all the Store classes also. But the sample shows how you can use your own POCO classes for the model.

如果您想从您的模型装配彻底清除Microsoft.AspNet.Identity.EntityFramework的依赖,你需要实现实现它具有以下接口的属性IIdentityStore接口的类:

If you want to completely remove the dependency on Microsoft.AspNet.Identity.EntityFramework from your model assembly you need to implement an class implementing the IIdentityStore interface which has properties of the following interfaces:


  • IUserLoginStore

  • IRoleStore

  • IUserSecretStore

  • ITokenStore

  • IUserClaimStore

  • IUserManagementStore

  • IUserStore

该IIdentityStore类应该在装配从模型组件分离,用你的模型集的引用。该IIdentityStore议会将依赖于ASP.Net身份的核心。

The IIdentityStore class should be in an assembly separate from your model assembly, with a reference to your model assembly. The IIdentityStore assembly would be dependent on ASP.Net Identity core.

您IIdentityStore的自定义实现需要somwhow能够转换和从你的POCO类ASP.Net身份接口,如IUSER,IUserSecret等。

Your custom implementation of IIdentityStore would need to somwhow be able to convert to and from your POCO classes to ASP.Net Identity interfaces such as IUser, IUserSecret etc.

在我看来,是而收效甚微了很多工作,如果你使用的是EF为你的店呢。

Seems to me to be a lot of work for little gain, if you are using EF for your stores anyway.

考虑在AspNet.Identity.Core组件的依赖,并有一些实现每一个微小的接口你的POCO类的,似乎简单多了给我。

Taking a dependency on the AspNet.Identity.Core assembly and have some of your POCO classes implementing one tiny interface each, seems a lot simpler to me.

这篇关于去耦Microsoft.AspNet.Identity。*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆