具有不一致用户 DN 的组的 rabbitmq ldap 授权

rabbitmq ldap authorization for groups with inconsistent user DNs

我正在尝试使用 in_groupin_group_nested 查询针对 LDAP (Microsoft Active Directory) 设置 rabbitmq 授权。然而,由于我们的 OU 结构在我们的用户之间不一致,这导致了各种 DN 模式,我不得不依赖一个 user_dn_pattern ,它只是在 "domain\account" 时传递绑定,从 Microsoft Active Directory 的身份验证角度来看效果很好。但是,当涉及到 in_group/in_group_nested 查询时,它不匹配,因为成员 属性 是实际 DN 的列表,并且日志显示它是试图在成员列表中找到 "domain\account"

由于 LDAP 插件需要一个单一的模式来从提供的用户名构造 DNs,我是否只是运气不好,无法在 RabbitMQ 中使用组级 LDA 授权?

即使考虑到 DN 不一致也应该是可能的,这里的问题似乎在于身份验证期间将用户名转换为 DN 的方式。

不要依赖 dn 模式,而是尝试通过 LDAP 查找。

关键是设置dn_lookup_bind在用户认证之前进行查找。这样,LDAP 插件将首先与这些凭据绑定以进行查找,然后与匹配条目的 DN 绑定以进行用户登录:

auth_ldap.dn_lookup_attribute = userPrincipalName     # or sAMAccountName
auth_ldap.dn_lookup_base = dc=example,dc=com          # restrict to user ou if any
auth_ldap.dn_lookup_bind = {managerDN, Password}      # AD manager account

# auth_ldap.user_dn_pattern should be left unset to be sure the lookup actually searches 
# for a match in dn_lookup_attribute and not for a built-up dn. 

我提到了来自 'AD manager' 的凭据,但它可以是任何具有足够权限对目标用户条目执行搜索的帐户。

鉴于该配置,当插件进入授权过程时,它可以使用实际用户 dn 正确处理组成员查找。


编辑 - 尽管文档说明了 auth_ldap.dn_lookup_bind

To do the lookup before binding, set auth_ldap.dn_lookup_bind to a tuple {UserDN, Password}.

显式设置可能更安全:

auth_ldap.dn_lookup_bind.user_dn = <UserDN>
auth_ldap.dn_lookup_bind.password = <Password>
# (OP was required to do so to make it work)

感谢上帝,我在这里找到了这个答案:)

如果有人有兴趣将此配置放入 高级 RabbitMQ 配置 文件,那么它看起来像这样 (连同 tag queries:

[{
  rabbitmq_auth_backend_ldap, [
    {dn_lookup_bind, {"CN=someuser,OU=somegroup,OU=othergroup,DC=example,DC=com", "crazypassword"}},
    {tag_queries, [
      {administrator, {in_group, "CN=groupname,OU=somegroup,OU=othergroup,DC=example,DC=com", "member"}},
      {management, {in_group, "CN=groupname,OU=somegroup,OU=othergroup,DC=example,DC=com", "member"}}
    ]}
  ]
}].

我在文档中找不到它。 谢谢EricLavault for this


BTW,我在 /etc/rabbitmq/conf.d/rabbitmq.conf 中的 Docker 集群中使用此配置:

cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-rabbitmq-1
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-rabbitmq-2
cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-rabbitmq-3
auth_backends.1 = internal
auth_backends.2 = ldap
auth_ldap.servers.1 = ldap.example.com
auth_ldap.port      = 636
auth_ldap.timeout   = 10000
auth_ldap.idle_timeout = 300000
auth_ldap.use_ssl   = true
auth_ldap.ssl_options.verify = verify_none
auth_ldap.dn_lookup_attribute = sAMAccountName
auth_ldap.dn_lookup_base = DC=example,DC=com
auth_ldap.user_dn_pattern = ${username}