ASP.NET MVC 中自定义帐户控制的用途
我正在创建一个自定义身份验证服务(我只需要比默认允许的更多的服务)。我无法决定是否应该扩展 MembershipUser 并实现适当的接口,或者完全推出我自己的接口。在扩展默认机制时,我自己滚动是否有任何优势,或者我应该注意哪些陷阱?
I'm creating a custom authentication service (I just need more than the default allows). I can't decide if I should extend MembershipUser and implement the appropriate interfaces, or completely roll my own. Is there any advantaged to rolling my own, or any pitfalls I should be aware of when extending the default mechanism?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你距离默认值还有多远?
如果您的需求与
MembershipProvider
为您提供的需求相去甚远,我建议您选择自己的需求。我个人还没有遇到过连接到现有数据存储的应用程序。因此,我们将向其中添加另一个应用程序。因此,我发现MembershipProvider
的设计方式有些过度。身份验证/授权通常也不需要花费太多时间来开发,并且您可以完全控制它。如果确实需要很长时间,那么它可能也与MembershipProvider
为您提供的时间相去甚远。但如果您的要求接近
MembershipProvider
,那么您应该考虑它。要么按原样,要么自己从中衍生。但要小心。这可能比交付您自己的内容花费更多的时间,因为您必须彻底学习它。安全管理要求
如果您使用 MembershipProvider(或您自己的继承类),您还可以获得 IIS 集成,因此可以轻松管理应用程序的安全设置。如果您自己推出,则还必须为此提供一个界面,这可能需要相当长的时间。
How far from defaults are you?
If your needs are far apart from what
MembershipProvider
gives you, I suggest you go with your own. I personally haven't come across an application that connected to an existing data store. So we would be adding another application to it. Hence I findMembershipProvider
way over engineered. Authentication/Authorisation usually also doesn't take too much time to develop and you control it completely. If it does take a lot of time it's probably also far from whatMembershipProvider
gives you.But if your requirements are close to
MembershipProvider
, then you should consider it. Either as it is or derive from it on your own. But beware. This may take more time than delivering your own, because you will have to learn it through and through.Security management requirements
If you go with MembershipProvider (or your own inherited class) you also get IIS integration so it's easy to manage security settings of your application. If you roll your own, you'll have to provide an interface for that as well which may take a considerable amount of time.
实现 MembershipProvider 抽象类。如果您需要的话,我这里有一个使用 XML 作为数据存储的实现。
http://msdn.microsoft。 com/en-us/library/system.web.security.membershipprovider.aspx?queryresult=true
Implement MembershipProvider abstract class. I have an implementation with XML as datastore right here, if you need it.
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx?queryresult=true
编写自己的提供程序总是很有趣,但这取决于您正在构建的应用程序的安全需求。
大多数情况下我都必须实现自己的提供程序。
好处是,如果您也需要,您可以在不同的提供商之间切换。
Its always good fun to write your own provider but it depends on the security needs of the application you are building.
Most occasions when I have had to implement my own provider.
Good thing is you can switch between different providers if you need too..