处理嵌套组权限(ASP.NET 角色提供程序)
我们有一个安全模块,它基于组/角色成员资格,控制对 ASP.Net 中资源的权限。我构建了一个自定义 ASP.Net 角色提供程序,用于查询 Active Directory 的组成员资格,并由该模块使用。
对于每个请求,安全检查的工作方式如下(出于性能原因在某些地方使用缓存,但不在此列表中):
- 查询 AD 以获取用户组成员身份列表
- 查询数据库以获取有权访问所请求资源的用户和组的列表
- 比较 AD 的结果与数据库的结果。如果用户明确拥有权限或者用户所在的组拥有权限,则允许访问,否则不允许访问。
当我们有嵌套组时就会出现问题。假设我们有两个组:ParentGroup 和 ChildGroup,其中 ChildGroup 是 Active Directory 中 ParentGroup 的成员,并且其中我们的用户是 ChildGroup 的成员。根据上面的逻辑,如果我们授予 ChildGroup 访问资源的权限,那么用户也可以访问该资源。
现在从逻辑上讲(无论如何对我来说)如果我们授予ParentGroup对资源的访问权限,那么它的所有成员以及递归获取的任何子组及其成员也应该能够访问所述资源。但相反,由于我的逻辑工作方式,他们无法访问资源。上面列表中的第 1 步看不到 ParentGroup,它只看到 ChildGroup,而步骤 2 只看到 ParentGroup,看不到 ChildGroup 。
所以问题是,为了让它按照我“逻辑上”描述的那样工作,我应该在哪里解决问题,以及是否有某种方法比另一种方法更好?
We have a security module which, based on group/role membership, controls permissions to resources in ASP.Net. I've built a custom ASP.Net Role Provider that queries Active Directory for group membership and which is used by this module.
Security checking works as follows for each request (caching used in places for performance reasons but excluded from this list):
- Query AD for list of users group memberships
- Query database for a list of users and groups with access to the requested resource
- Compare results from AD with results from the database. If the user explicitly has rights or if a group that the user is in has rights then allow access, else don't.
The problem arises when we have nested groups. Lets say we have two groups: ParentGroup and ChildGroup, where ChildGroup is a member of ParentGroup in Active Directory and where our user is a member of ChildGroup. According to the logic above if we give ChildGroup access to a resource then then the user can access the resource too.
Now logically (to me anyways) if we give ParentGroup access to a resource then all members of it, and any sub groups and their members acquired recursively, should also be able to access said resource. But instead, because of the way my logic works they can't access the resource. Step 1 from the above list does not see ParentGroup it only see's ChildGroup, and Step 2 only see's ParentGroup and does not see ChildGroup.
So the question is, to make it work how I described it "Logically" should, where should I fix the problem, and is there some method that would work better then another?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 WindowsPrincipal.IsInRole() 方法而不是直接查询 AD 。我在这里发布了一些示例代码,其中可能有帮助。
Try using the WindowsPrincipal.IsInRole() method instead of querying AD directly. I posted some sample code over here which might help.