1

我在实现通过正则表达式授予 OpenLDAP 实例的一些权限方面遇到了一些问题,已经有好几个小时了——可能有人可以提供帮助;)

我希望一个组的成员管理一个树结构,该组是它的成员。我已经尝试了一些 acl 设置——我将在基本结构下发布我的试验。

(抱歉这么长的问题)


基本结构

这个结构有点像那棵树——在一个#符号后面,有一个简短的描述条目的含义。

dc=example,dc=com
│
├── cn=admin                  # OpenLDAP default admin user 
│
├── ou=entities               # organisational entities
│   │
│   ├── o=e1                  # first of these entities
│   │   │
│   │   ├── cn=admin          # groupOfNames – see bullet points below
│   │   │   ┆
│   │   │   └ ┄▸ member: cn=admin,dc=example,dc=com
│   │   │   └ ┄▸ member: uid=j.doe,ou=people,dc=example,dc=com
│   │   │
│   │   ├── cn=role1          # groupOfNames to be reused below
│   │   │   ┆                   as recursive group members within
│   │   │   ┆                   permission groups
│   │   │   ┆
│   │   │   └ ┄▸ member: cn=admin,o=e1,ou=entities,dc=example,dc=com
│   │   │
│   │   └── cn=role2
│   │       ┆
│   │       └ ┄▸ member: cn=admin,o=e1,ou=entities,dc=example,dc=com
│   │
│   └── o=e2
│       ├── cn=admin
│       ├── cn=role1
│       └── cn=role2
│
├── ou=groups                 # permission groups for applications
│   │                           that authenticate against OpenLDAP
│   │
│   ├── cn=globaladmins       # groupOfNames – superusers in all applications
│   │   ┆
│   │   └ ┄▸ member: cn=admin,dc=example,dc=com
│   │
│   ├── cn=ldapadmins         # groupOfNames – same rights as admin user
│   │   ┆
│   │   └ ┄▸ member: cn=globaladmins,ou=groups,dc=example,dc=com
│   │   └ ┄▸ member: uid=l.dap,ou=people,dc=example,dc=com
│   │
│   ├── cn=permissiongroup1   # groupOfNames – authentication group
│   │   ┆                       for specific application
│   │   ┆
│   │   └ ┄▸ member: cn=globaladmins,ou=groups,dc=example,dc=com
│   │   └ ┄▸ member: cn=role1,o=e1,ou=entities,dc=example,dc=com
│   │   └ ┄▸ member: cn=role1,o=e2,ou=entities,dc=example,dc=com
│   │
│   └── cn=permissiongroup2
│       ┆
│       └ ┄▸ member: cn=globaladmins,ou=groups,dc=example,dc=com
│       └ ┄▸ member: cn=role2,o=e1,ou=entities,dc=example,dc=com
│       └ ┄▸ member: cn=role2,o=e2,ou=entities,dc=example,dc=com
│
└── ou=people                 # finally the "real people" accounts
    │
    ├── uid=j.doe
    ├── uid=l.dap
    └── uid=m.muster
  • cn=admin,dc=example,dc=comadmin组的基本成员(因为每个组都需要至少一个成员)。
  • uid=l.dap,ou=people,dc=example,dc=com是该cn=ldapadmins,ou=groups,dc=example,dc=com组的成员。因此,每个成员在 LDAP 结构中都应具有与cn=admin,dc=example,dc=com
  • ou=people是唯一的结构,(个人)帐户得到维护
  • ou=groups是唯一的结构,维护(Web)应用程序的身份验证组(具有嵌套成员)

.

  • cn=admin,o=e1,ou=entities,dc=example,dc=comDN 成员应该能够管理以下所有内容o=e1,ou=entities,dc=example,dc=com
  • e1应该是动态的。
  • 实体管理员不应该能够管理除这些实体之外的其他实体,他们是来自的管理员。

权限 LDIF

我尝试了一些不同的东西......并且没有一个正则表达式成功:(

由于我将发布一些片段,因此我将每个 LDIF 片段放在这样的 bash 片段中:

touch /permissions.ldif

cat >/permissions.ldif <<EOF
# first of all delete all permissions
dn: olcDatabase={1}mdb,cn=config
changetype: modify
delete: olcAccess
-


########
## LDIF blocks from below
########


-
# add general permissions
add: olcAccess
olcAccess: to *
           by self write
           by dn="cn=admin,dc=example,dc=com" write
           by set="[cn=ldapadmins,ou=groups,dc=example,dc=com]/member* & user" write
           by users read
           by * none
EOF

ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f /permissions.ldif

试验 1

# add administrative access to LVe admin subgroups
add: olcAccess
olcAccess: to dn.regex="([^,]+,)?o=([^,]+),ou=entities,dc=example,dc=com"
           by self write
           by dn="cn=admin,dc=example,dc=com" write
           by set="[cn=ldapadmins,ou=groups,dc=example,dc=com]/member* & user" write
           by set.expand="[cn=admin,o=$2,ou=entities,dc=example,dc=com]/member* & user" write
           by set="this/member* & user" read
           by * none

结果是,admin任何成员都ldapadmins可以编辑,特定实体admin子组的成员无法编辑。

特定admin的子组甚至看不到entities子树。


试验 2

# add administrative access to LVe admin subgroups
add: olcAccess
olcAccess: to dn.regex="o=([^,]+),ou=entities,dc=example,dc=com"
           by self write
           by dn="cn=admin,dc=example,dc=com" write
           by set="[cn=ldapadmins,ou=groups,dc=example,dc=com]/member* & user" write
           by set.expand="[cn=admin,o=$1,ou=entities,dc=example,dc=com]/member* & user" write
           by set="this/member* & user" read
           by * none

与试验 1 相同的结果...


试验 3

附加组 - 作为树:

dc=example,dc=com
┆
└── ou=entity_admins
    │
    ├── cn=e1
    │   ┆
    │   └ ┄▸ member: cn=admin,o=e1,ou=entities,dc=example,dc=com
    │
    └── cn=e2

和 LDIF:

# add administrative access to LVe admin subgroups
add: olcAccess
olcAccess: to dn.regex="o=([^,]+),ou=entities,dc=example,dc=com"
           by self write
           by dn="cn=admin,dc=example,dc=com" write
           by set="[cn=ldapadmins,ou=groups,dc=example,dc=com]/member* & user" write
           by set.expand="[cn=$1,ou=entity_admins,dc=example,dc=com]/member* & user" write
           by set="this/member* & user" read
           by * none

结果又是这样:admin任何成员都ldapadmins可以编辑,entity_admins子组用户不能编辑——即使不是他们的“拥有”实体。


试验 4

如果我by set="[cn=admin,o=e1,ou=entities,dc=example,dc=com]/member* & user" write每一个单曲添加一个olcAccess: to dn.regex="([^,]+,)?o=jpbay,ou=entities,dc=example,dc=com"(与试验 1 中的所有其他东西一起),一切正常。

但是:这不是可维护的或动态的。所以这不是解决办法,我可以接受。


我不知道为什么set.expand不能按预期工作(正如 openldap.com 上的不同在线示例中所解释的那样) - 并且无法找到可以解释原因的适当文档。或者是否必须启用 OpenLDAP 模块?

如果你能在这个问题上支持我——可能有一个解决方案——那就太好了=)

非常感谢,马丁

4

0 回答 0