基于asp.net mvc3的web项目自定义安全管理的建议
我有一个使用 asp.net mvc3 的 Web 项目。现在客户要求安全管理功能。以下是该项目的一些背景:
- 使用表单身份验证的公共网站。
- 客户希望自我管理安全性(包括角色、用户、对资源的操作)。
- 用户是项目的域模型。
- 访问控制的粒度至少应该达到操作级别(当用户执行未经授权的操作时,向用户返回未经授权的页面)。但最好根据用户的授权更改视图内容(在视图页面上动态仅显示授权的元素)。
我不太擅长 asp.net mvc 。我不知道内置的memberprovider和roleprovider是否可以满足这个需求。但我更喜欢建立自己的模型提供程序(资源类别、操作、角色、组等)以实现完全控制。但似乎还有其他因素需要关注,例如缓存、性能或其他因素。
有人可以给我一些关于如何实现此功能以及如何将其应用到我的项目中的建议吗?更好一些示例项目。
多谢
I have a web project using asp.net mvc3. Now clients ask for a security management feature. Here's some context of this project:
- A public web site using form authentication.
- Client wants to self-management the security.(including roles, users, actions on resources).
- User is a domain model of the project.
- Granularity of access controll should at least goes to action level (return an unauthorized page to user when user do an unauthorized action). But it is preferred to change view content based on user's authorization (dynamically show only authorized elements on view page).
I'm not quite good at asp.net mvc . I don't know whether the build-in memberprovider and roleprovider is OK for this requirement. But I prefer to build up my own model provider for (resource categories, actions, roles, group etc.) for totally control. But there seems to be other factors to concern like cache, performance or something else.
Can someone give me some advices on how to implementing this feature and how to apply it into my project? Better some sample projects.
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我采用的方法几乎可以归结为一个访问控制列表,它是一系列键来表示访问类型以及一系列键类型的位值操作(读取、插入、修改和删除)。
整个站点通过使用 ajax 和 json 的 REST 风格 API 进行填充。每一项功能都包含一系列权限测试(我缓存了访问控制列表)。
示例场景:
用户(管理员)正在访问用户列表。
这将需要为正在执行的代码评估以下访问键和操作:
,这些条件是与登录用户分配的角色以及与该角色关联的访问控制权限进行比较的。
通过存储在数据库中的访问列表和权限,用户可以更改分配给哪些角色的访问项目和操作。
因为您将赋予用户修改这些关联的能力,所以为每个访问控制项添加描述会非常有益。 >
祝你好运!
The approach I take pretty much boils down to an Access Control List that is a series of keys to represent the type of access and a series of bit values for the type of action (Read, Insert, Modify, and Delete).
The whole site is populated via a REST style API utilizing ajax and json. Each piece of functionality is wrapped with a series of permission tests (I cache the Access Control List).
Example scenario:
User (Admin) is accessing a list of users.
This would call for the following Access keys and actions to be evaluated for the code being executed:
Obviously these conditions are compared to the logged in user's assigned role and the Access Control permission associated to that role.
With thee access list and permissions stored in the database a user can alter what access item and action is assigned to which roles.
Because you're going to give the users the ability to modify these associations it would be very beneficial to add a description for each Access Control item.
Good luck!