处理嵌套组权限(ASP.NET 角色提供程序)

发布于 2024-10-07 02:00:08 字数 839 浏览 0 评论 0原文

我们有一个安全模块,它基于组/角色成员资格,控制对 ASP.Net 中资源的权限。我构建了一个自定义 ASP.Net 角色提供程序,用于查询 Active Directory 的组成员资格,并由该模块使用。

对于每个请求,安全检查的工作方式如下(出于性能原因在某些地方使用缓存,但不在此列表中):

  1. 查询 AD 以获取用户组成员身份列表
  2. 查询数据库以获取有权访问所请求资源的用户和组的列表
  3. 比较 AD 的结果与数据库的结果。如果用户明确拥有权限或者用户所在的组拥有权限,则允许访问,否则不允许访问。

当我们有嵌套组时就会出现问题。假设我们有两个组:ParentGroupChildGroup,其中 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):

  1. Query AD for list of users group memberships
  2. Query database for a list of users and groups with access to the requested resource
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热鲨 2024-10-14 02:00:08

尝试使用 WindowsPrincipal.IsInRole() 方法而不是直接查询 AD 。我在这里发布了一些示例代码,其中可能有帮助。

Try using the WindowsPrincipal.IsInRole() method instead of querying AD directly. I posted some sample code over here which might help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文