ASP.NET:权限/验证体系结构 [英] ASP.NET: Permission/authentication architecture

查看:132
本文介绍了ASP.NET:权限/验证体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待到在我的ASP.NET应用程序具有以下要求的建设的验证

I am looking into building an authentication in my ASP.NET application with the following requirements.


  • 的用户都只有一个角色(即管理员,销售经理,销售,....)

  • 角色都有一组权限来访问CRUD现有对象的一个​​子集。即
    销售有CREAD,READ,对象类型WRITE权限产品,而不是删除

  • 不知怎的,我喜欢的权限是在一个层次中继承,以便为我联系,即不需要指定所有可用的对象。

  • 系统必须迅速能够回答这个问题:是否用户X权限去做Y以反对Z

  • 所有的数据库管理(MSSQL),在C#/ ASP.NET
  • 实施

我想获得这些要求的反馈?任何想法如何实现这一点使用ASP.NET框架(尽可能)? (不过,我也有兴趣知道如何可以在不成员实现)

I would like to get feedback on these requirements? Any ideas how to implement this using ASP.NET framework(as much as possible)? (However, I'm also interested to know how this can be achieved without Memberships)

推荐答案

我认为你需要什么做的,是实现一组权限查询方法在任何业务对象或控制器。例如:的CanRead(),CanEdit(),CanDelete()

I think what you need to do here is implement a set of permissions query methods in either your business objects or your controller. Examples: CanRead(), CanEdit(), CanDelete()

当页面呈现,它需要查询业务对象,并确定用户的授权的功能,并启用或禁用基于该信息的功能。业务对象可以反过来,使用角色或额外的数据库查询来确定当前用户的权限。

When the page renders, it needs to query the business object and determine the users authorized capabilities and enable or disable functionality based on this information. The business object can, in turn, use Roles or additional database queries to determine the active user's permissions.

我不能想办法以声明方式集中定义这些权限。他们需要被分配到的函数的实现。如果你想要做的改进设计,不过,你可以使用依赖注入插入授权人到您的业务对象,从而保持实现分离。

I can't think of a way to declaratively define these permissions centrally. They need to be distributed into the implementation of the functions. If you want do improve the design, however, you could use dependency injection to insert authorizers into your business objects and thus keep the implementations separate.

有是一个使用在洛基Lhotka的书这一模式的一些code。新版本是不是在<一个href=\"http://books.google.com/books?id=AS7zAQaKt-oC&pg=PA303&lpg=PA303&dq=ApplyAuthorizationRules()&source=web&ots=KAM2jFW5DR&sig=CH2iXpBw1K5i5zSnyA8sEJWjKlM&hl=en&sa=X&oi=book_result&resnum=7&ct=result\"相对=nofollow>谷歌尚未的

There's some code that uses this model in Rocky Lhotka's book. The new version isn't in Google yet.

这篇关于ASP.NET:权限/验证体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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