一般狀況下,用戶訪問SVN服務器分紅驗證和受權兩個部分,SVN自己內置了驗證和受權的機制,默認是使用明文,可使用其餘模塊作成加密,但這種方式很是繁瑣,最終的效果也不盡如人意。所幸SVN提供了對sasl的支持,這樣,對於用戶的驗證和受權,咱們就有了更多的選擇。html
什麼是SASL?我在Subversion官方文檔上找到這樣一段介紹:web
What Is SASL?vim
The Cyrus Simple Authentication and Security Layer is open source software written by Carnegie Mellon University. It adds generic authentication and encryption capabilities to any network protocol, and as of Subversion 1.5 and later, both the svnserve server and svn client know how to make use of this library. It may or may not be available to you: if you're building Subversion yourself, you'll need to have at least version 2.1 of SASL installed on your system, and you'll need to make sure that it's detected during Subversion's build process. If you're using a prebuilt Subversion binary package, you'll have to check with the package maintainer as to whether SASL support was compiled in. SASL comes with a number of pluggable modules that represent different authentication systems: Kerberos (GSSAPI), NTLM, One-Time-Passwords (OTP), DIGEST-MD5, LDAP, Secure-Remote-Password (SRP), and others. Certain mechanisms may or may not be available to you; be sure to check which modules are provided.You can download Cyrus SASL (both code and documentation) from http://asg.web.cmu.edu/sasl/s...安全
大意是,簡單認證與安全層是卡內基梅隆大學出品的一個開源軟件(準確的說,是John Gardiner Myers寫的),它將通用的身份驗證和加密功能添加到任何網絡協議,從1.5版本之後,Subversion(這是SVN的全稱……)服務端和客戶端都知道如何使用這個庫。如下狀況將決定SASL是否可用:若是你打算自行編譯SVN並使SASL可用,那麼必須安裝2.1或者更高的SASL版本,而且保證在編譯期間,你安裝的SASL能被編譯進程檢測到。若是你使用預先編譯好的二進制包,你須要聯繫維護者肯定SASL特性支持已經被編譯進去了。SASL使用各類模塊來對應不一樣的身份驗證系統:Kerberos (GSSAPI), NTLM, One-Time-Passwords (OTP), DIGEST-MD5, LDAP, Secure-Remote-Password (SRP)等,某種驗證機制是否可用,取決於你是否擁有這種機制對應的模塊。你能夠從http://asg.web.cmu.edu/sasl/s... 下載Cyrus SASL。服務器
基本的介紹就寫到這裏,下面展現如何安裝並配置SVNSASL,使得SVN經過sasl使用LDAP身份驗證。基於CentOS7。網絡
yum install -y subversion cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
[root@localhost ~]# saslauthd -v saslauthd 2.1.26 authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap httpform #此處提供了對LDAP的支持。
cp /etc/sysconfig/saslauthd /etc/sysconfig/saslauthd.save sed -i 's/MECH=pam/MECH=ldap/' /etc/sysconfig/saslauthd
ldap_servers: ldap://ldapserver #填寫你的服務器,域名或者IP都可,前提是你的DNS能正常工做 ldap_default_domain:domain.com #默認域名 ldap_search_base:DC=domain,dc=com # ldap_bind_dn:domain\user ldap_password:password ldap_deref: never ldap_restart: yes ldap_scope: sub ldap_use_sasl: no ldap_start_tls: no ldap_version: 3 ldap_auth_method: bind ldap_mech: DIGEST-MD5 ldap_filter:sAMAccountName=%u ldap_password_attr:userPassword ldap_timeout: 10 ldap_cache_ttl: 30 ldap_cache_mem: 32786 此處是填寫的LDAP協議的各個要素。
systemctl restart saslauthd.service testsaslauthd -u user -p 'password' #分別替換就是了。
vi /etc/sasl2/svn.conf pwcheck_method:saslauthd #用戶驗證方法 mech_list: plain login #用戶驗證信息怎麼傳輸
vim /yourrepository/conf/svnserve.conf [general] anon-access = none auth-access = write #password-db = passwd #關閉passwd authz-db = authz #若是要對版本庫進行權限控制,開啓authz [sasl] use-sasl = true #開啓sasl用戶驗證
重啓SVN的時候要使用 -d -r參數指定倉庫。受權部分就很簡單了。按照dom
[/path] username = r username = rw #沒寫就是沒權限……用@符號表示用戶組,用戶組的建立就是 groupname = user1,user2,