OpenLDAP 限制匿名访问只能查看条目属性而不能扫描整个数据库

OpenLDAP 限制匿名访问只能查看条目属性而不能扫描整个数据库

我们有一个 OpenLDAP (2.4.45) 服务器,其中包含我们所有的用户、组、sudo 规则等。

我需要将新的应用程序连接到该服务器,但是该应用程序要求匿名用户可以读取属性(它将知道需要读取属性的确切 DN)。

现在假设结构如下:

o=Example(dc=example,dc=com)
  ou=People
    uid=user1
    uid=user2
  ou=Groups
    cn=group1
    cn=group2

我需要限制匿名用户如果知道确切的 DN(例如 dn="uid=user1,ou=People,dc=example,dc=com")则可以获取用户的所有属性,并且完全无法发现其他记录(如果他们不知道确切的 DN)。

通过阅读 OpenLDAP 文档,我假设以下 ACL 应该有效:

olcAccess: {0}to dn.children="ou=Groups,dc=example,dc=com"
  by * read break
olcAccess: {1}to *
  by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
  by anonymous none stop
  by * read

然而,它似乎breakstop没有产生预期的结果,因为直接对“cn = test,ou = Groups,dc = example,dc = com”的查询会导致No such object (32)

实现上述目标的正确方法是什么?

答案1

其实答案很简单(在 IRC 中指出了这一点):

ACL 应如下:

olcAccess: {0}to dn.children="ou=Groups,dc=example,dc=com"
  by anonymous stop
  by * read break
olcAccess: {1}to *
  by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
  by anonymous none stop
  by * read

请注意stop{0} 中的行,在原始 ACL 中,它首先授予读取访问权限,但随后将其删除,因为break在新版本中,匿名者明确授予了读取访问权限,然后 OpenLDAP 告知停止处理此请求的 ACL。

相关内容