svnserve+sasl+ldap:saslauthd 没有联系?

use*_*387 5 ldap saslauthd svnserve

我正在尝试针对 sasl+ldap 对 subversion 用户进行身份验证。关于这个问题的其他问题似乎与早期版本的 subversion 或 sasldb 身份验证有关。

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.1 (jessie)
Release:    8.1
Codename:   jessie

svnserve --version
svnserve, version 1.8.10 (r1615264)
Cyrus SASL authentication is available.

saslauthd -v
saslauthd 2.1.26
authentication mechanisms: sasldb getpwent kerberos5 pam rimap shadow ldap
Run Code Online (Sandbox Code Playgroud)

sasl+LDAP 部分似乎已正确配置:

testsaslauthd -u user -p password -r realm
0: OK "Success."
Run Code Online (Sandbox Code Playgroud)

使用错误的凭据对其进行测试会出现错误:

testsaslauthd -u wronguser -p wrongpassword -r wrongrealm
0: NO "authentication failed"
Run Code Online (Sandbox Code Playgroud)

它在 auth.log 中显示错误:

Sep 10 22:23:53 xxx saslauthd[30948]: Entry not found ((&(objectClass=posixAccount)(uid=wronguser))).
Sep 10 22:23:53 xxx saslauthd[30948]: Authentication failed for wronguser/wrongrealm: User not found (-6)
Sep 10 22:23:53 xxx saslauthd[30948]: do_auth         : auth failure: [user=wronguser] [service=imap] [realm=wrongrealm] [mech=ldap] [reason=Unknown]
Run Code Online (Sandbox Code Playgroud)

所以我假设 SASL 可以很好地联系 LDAP 服务器并获取数据。

我配置了颠覆:

/etc/sasl2/svn.conf:
pwcheck_method: saslauthd
mech_list: DIGEST-MD5
Run Code Online (Sandbox Code Playgroud)

使用 strace -e open 检查 svnserve 表明它打开了这个文件,而不是 /usr/lib/sasl2 或类似文件。

当我尝试从 svn 客户端连接时,我得到

Sep 10 22:31:38 xxx svnserve: DIGEST-MD5 common mech free
Run Code Online (Sandbox Code Playgroud)

在每次尝试的 auth.log 中,但没有来自 saslauthd 的信息或错误。

如果我将用户帐户添加到 sasldb2:

saslpasswd2 user -u realm
Password: password
Run Code Online (Sandbox Code Playgroud)

我可以从 svn 客户端正确连接。所以看起来 sasl 使用 sasldb2,即使 svn 和 saslauthd 的配置配置了 LDAP。

use*_*387 1

解决方案: 我附加了一个调试器并逐步完成身份验证。结果我遇到了两个问题: /var/log/saslauthd 的权限:

drwx--x---  2 root        sasl         140 Sep 27 09:44 saslauthd
Run Code Online (Sandbox Code Playgroud)

意味着“subversion”服务器用户需要是 sa​​sl 组的一部分。

第二个更复杂:DIGEST-MD5 依赖纯文本密码在服务器端计算哈希值。我的LDAP目录存储SSHA加密的密码,因此服务器永远无法将客户端的MD5与本地计算的MD5进行比较。我猜想该目录可以存储 MD5(用户名:领域:密码),但我不确定 sasl 是否支持这一点,以及如果您有多个领域,您将如何管理它。

我真的不想存储纯文本密码,所以现在的解决方案是仅使用未加密的身份验证:

# cat /etc/sasl2/svn.conf
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
Run Code Online (Sandbox Code Playgroud)

这不是一个完美的解决方案,但目前看来可行。我想我会强制使用 ssh+svn 进行外部访问,也许我会投入一些时间来支持 svnserve 的 TLS。

(如果有更多的诊断选项和更好的文档,这将大大减少耗时。)