您的位置:首页 > 其它

借助sasl构建基于AD用户验证的SVN服务器

2016-09-07 14:36 316 查看
SVN服务器的用户验证方式很多,以下列出一些我所了解的:

1 最简单的,即使用SVN版本库目录之下的conf/passwd文件存储用户信息。然而,密码使用了明文存储,有安全隐患。

2 SVN+sasl实现密码加密,我参考网上资料:
http://www.cnblogs.com/linn/archive/2011/08/04/2127014.html
进行了实验,该方式使用了另外的可自定义的sasldb文件来存储用户信息,然而,似乎没有实现加密的效果,初看之下,sasldb文件确实一堆乱码,但仔细看看,发现密码仍然是明文的,莫非我操作有偏差?更重要的是,这种方式使得用户管理极其麻烦。

3 既然提到了sasl,sasl提供各种用户验证方式,例如MySQL、AD域等,非常理想,但查找资料发现,大多依赖于Apache,这意味着我们将使用http://、https://方式来使用SVN,这是令人讨厌的,性能也必然有所下降。

4 SVN+sasl+AD,令人愉快的是,剔除Apache,借助saslauthd构建基于AD用户验证的SVN服务器仍然是可行的,使用SVN自己的svn://协议进行通信。

 

本文将讲述第4种方案的实现方法。

 

环境说明:

SVN的安装、AD服务器的搭建、域帐号的添加等琐碎不在本文关心之列,以我所在环境为例,假设环境基础已经完备:

1 AD服务器

         操作系统:WindowsServer 2012 R2 Datacenter

         域:ad.com

         IP:10.17.1.2

         SVN域帐号:pub-svn+pw000000(密码应配置为不可更改,永不过期)

         SVN测试用户域帐号:test+pw111111

 

2SVN服务器

         操作系统:CentOS7.1 x64

         IP:10.17.1.10

         版本库:/home/svn/project_art

 

Step by Step!

 

1 检查是否已经安装cryus-sasl:

[root@localhostproject_art]# rpm -qa | grep cyrus-sasl

cyrus-sasl-lib-2.1.26-17.el7.x86_64

cyrus-sasl-2.1.26-17.el7.x86_64

cyrus-sasl-plain-2.1.26-17.el7.x86_64

cyrus-sasl-gssapi-2.1.26-17.el7.x86_64

cyrus-sasl-scram-2.1.26-17.el7.x86_64

cyrus-sasl-md5-2.1.26-17.el7.x86_64

 

如果没有安装则安装之:

[root@localhost project_art]#yum-y install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain

 

2 查看sasl的用户验证方式:

[root@localhostproject_art]# saslauthd -v

saslauthd 2.1.26

authenticationmechanisms: getpwent kerberos5 pam rimap shadow ldap httpform

我们要使用的AD验证方式便依靠ldap提供支持。

 

3 修改sasl的用户验证方式为ldap:

[root@localhostproject_art]# vi /etc/sysconfig/saslauthd

# Directory in which toplace saslauthd's listening socket, pid file, and so

# on.  This directory must already exist.

SOCKETDIR=/run/saslauthd

 

# Mechanism to use whenchecking passwords.  Run "saslauthd-v" to get a list

# of which mechanismyour installation was compiled with the ablity to use.

# MECH=pam

MECH=ldap

 

# Additional flags topass to saslauthd on the command line. See saslauthd(8)

# for the list ofaccepted flags.

FLAGS=

 

4 修改sasl配置文件/etc/saslauthd.conf,如果配置文件不存在,touch之:

[root@localhostproject_art]# vi /etc/saslauthd.conf

#AD服务器地址,写域名或IP都行

ldap_servers:ldap://ad.com

#AD默认域名

ldap_default_domain:ad.com

#用户信息查找配置,组织与单位OU为GZY,要查找所有组织单位,则不填写OU

#ldap_search_base: OU=GZY,DC=ad, DC=com

ldap_search_base: DC=ad,DC=com

#SVN的域帐号

#ldap_bind_dn:CN=pub-svn, OU=GZY, DC=ad, DC=com

ldap_bind_dn: ad\pub-svn

#ldap_bind_pw:pw000000

ldap_password: pw000000

#其他设置

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

 

5 重启sasl服务:

[root@localhost project_art]#systemctl restart saslauthd.service

重启后测试一下能否正常连接到AD域:

[root@localhostproject_art]# testsaslauthd -u test -p 'pw111111'

0: OK"Success."

如果连接失败,检查配置,找一下问题所在吧。

 

6 修改SVN的sasl配置文件/etc/sasl/svn.conf,同样,如果配置文件不存在,touch之:

[root@localhostproject_art]# vi /etc/sasl2/svn.conf

#用户验证方法

pwcheck_method:saslauthd

#用户验证信息怎么传输

mech_list: plain login

由于svn.conf依赖于saslauthd.conf,不需要配置过多内容,svn.conf也可以按照saslauthd.conf进行配置,这时它的配置选项有更高的优先级。

 

7 修改SVN版本库的配置:

[root@localhostproject_art]# vi /home/svn/project_art/conf/svnserve.conf

 [general]

anon-access = none

auth-access = write

#关闭passwd

# password-db = passwd

#如果要对版本库进行权限控制,开启authz

authz-db = authz

 [sasl]

#开启sasl用户验证

use-sasl = true

 

8 重启SVN:

[root@localhos
c1ac
tproject_art]# ps -ef | grep svn

root     17131    1  0 14:30 ?        00:00:00 svnserve -d

root     18040 13803  0 15:57 pts/1    00:00:00 grep --color=auto svn

[root@localhostproject_art]# kill 17131

[root@localhostproject_art]# svnserve -d

 

有点暴力,SVN还有其他重启方式吗,Tell me!

 

9 到域用户客户端连接SVN服务器验证一下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: