ASP.NET用户身份,并在多站点角色 [英] ASP.NET Identity User and Roles in Multisite

查看:162
本文介绍了ASP.NET用户身份,并在多站点角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在ASP.NET MVC应用程序创建的权限系统。我一直在学习最新的身份框架 - 这里是我的要求:

I am trying to create a permissions system in an ASP.NET MVC Application. I have been learning the newest Identity framework - here are my requirements:


  1. 一组为每组的功能分层角色的。所以,举例来说,可能有以下作用:

    • 继承

    • 阅读

    • 编辑

    • 管理

    • 管理

通过扩展ASP.NET身份,它是将有可能为我做到这一切的?或者我应该可以定制从地面向上构建的东西吗?

Through extending ASP.NET Identity, is it going to be possible for me to accomplish all of this? Or should I be building something custom from the ground-up?

推荐答案

9,999超时10000实现自己的认证系统是错误的路要走。什么是比这更容易,这是一个看似很难做到的右键的事情。 ASP.NET身份实际上是pretty定制的,因为它是专门为此目的创建的。你可能需要做相当多的充分引导你的定制要求,但使用ASP.NET识别它几乎肯定会更快,更安全。

9,999 times out of 10,000 implementing your own authentication system is the wrong way to go. Anything is easier than that, and it's a deceptively difficult thing to do right. ASP.NET Identity is actually pretty customizable, as it was created specifically for that purpose. You might need to do quite a bit to bootstrap your custom requirements fully, but it'll almost certainly be quicker and more secure using ASP.NET Identity.

更新

的UserManager 的构造函数 IUserStore 的实现。当与实体框架的工作,你通常只给它<一个href=\"http://msdn.microsoft.com/en-us/library/dn315446%28v=vs.111%29.aspx\"><$c$c>Microsoft.AspNet.Identity.EntityFramework.UserStore,但是这是你的点扩展领带。所以,你可以简单地继承 UserStore ,然后覆盖类似 GetRolesAsync 做任何自定义角色的逻辑需要实现。然后,你只给的UserManager 子类。

UserManager's constructor takes an implementation of IUserStore. When working with Entity Framework, you typically just feed it Microsoft.AspNet.Identity.EntityFramework.UserStore, but this is your tie in point for extensibility. So, you can simply subclass UserStore and then override something like GetRolesAsync to do whatever custom role logic you need to implement. Then you'd just feed UserManager your subclass.

这篇关于ASP.NET用户身份,并在多站点角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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