上一篇文章咱們介紹了LDAP的部署以及管理維護,那麼如何接入LDAP實現帳號統一認證呢?這篇文章將帶你完成svn的接入驗證html
# a2enmod ldap
Enabling module ldap.
To activate the new configuration, you need to run:
service apache2 restart
# a2enmod authnz_ldap
Considering dependency ldap for authnz_ldap:
Module ldap already enabled
Enabling module authnz_ldap.
To activate the new configuration, you need to run:
service apache2 restart
複製代碼
<Virtualhost *:8088>
DocumentRoot /home/svn/repos/
ServerName svn.blz.netease.com
<Location /ne/>
DAV svn
SVNListParentPath on
SVNParentPath "/home/svn/repos"
AuthType Basic
AuthName "Netease&Blizzard Subversion Repository"
#AuthUserFile "/etc/subversion/dav_svn.passwd"
AuthzSVNAccessFile "/etc/subversion/dav_svn.authz"
# use LDAP auth
AuthBasicProvider ldap
AuthLDAPBindAuthoritative on
AuthLDAPURL "ldap://ldap.blz.netease.com/dc=blz,dc=internal?uid?sub?(objectclass=*)"
AuthLDAPBindDN "uid=authz,ou=Public,dc=blz,dc=internal"
AuthLDAPBindPassword "ImNVZODT884"
Require ldap-user
</Location>
</Virtualhost>
複製代碼
AuthzLDAPAuthoritative
,到2.4中改成了AuthLDAPBindAuthoritative
可能只看配置文件不能瞭解LDAP認證的原理,接下來咱們詳細討論下LDAP是如何認證的apache
客戶端(httpd)使用提供的URL(AuthLDAPURL)進行驗證的時候,並非直接驗證輸入的帳號密碼,由於LDAP服務器在驗證的時候要使用DN(每一個節點用戶的惟一標識)和密碼來進行登錄驗證的,可是DN通常來講比較長,諸如:「cn=xxx,ou=xxx,ou=xxx,dc=xxx,dc=xxx」,這種光輸入的時候就煩氣了,因此要想使用簡短的用戶名來登錄的時候,通常的作法是在某個節點用戶上添加一個屬性,好比mobile(手機號),Email(郵箱),user name或者uid(用戶名),而後使用這個屬性的值來登錄(大部分狀況下都用uid,咱們也是這麼使用的)。安全
當用戶輸入這個屬性值(通常uid)和密碼的時候,客戶端(httpd服務器)先使用AuthLDAPBindDN和AuthLDAPBindPassword做爲用戶名和密碼登錄,根據AuthLDAPURL指定的查詢規則來查找用戶輸入的屬性的值有沒有,若是查找的條數爲0或者大於1,則返回錯誤,若是查找的條數等於1,則使用查找到的這個條目的DN和用戶輸入的密碼進行登錄驗證,成功則成功,失敗則失敗。bash
總結一下LDAP的認證過程分爲兩部:服務器