Subversionをsvnserveで公開し、ActiveDirectory(LDAP)認証と統合する
DebianにSubversionをインストールして、Eclipseプラグインから接続してみました。Debianにsubversionをインストールし、Eclipseプラグイン経由で接続
svnのパスワードファイル「/var/svn/conf/passwd」を編集してユーザーを
追加するのが面倒なので、ActiveDirectoryと連携し、認証を行いたいと思います。
Apacheをフロントに置いたActiveDirectory連携は見かけるのですが、svnserveで
公開しているリポジトリの認証をActiveDirectoryでっていうのはあまり
見つけられなかったのでメモしておきます。
SASLのインストールと設定
設定は、以下のURLを参考に行いました。
SVN with LDAP via SASL
svnserveの認証をActiveDirectory(LDAP)に委譲するには、SASLを使えばよいようです。
SASL: Cyrus SASL Library
まず、SASLのインストールを行います。
# apt-get install sasl2-bin
...(中略)
update-rc.d: warning: saslauthd stop runlevel arguments (0 1 6)
do not match LSB Default-Stop values (1)
To enable saslauthd, edit /etc/default/saslauthd and set START=yes ... (warning).
「/etc/default/saslauthd」の設定ファイルを編集して、START=yesにしろとのことなので、
言われたとおりにします。
# vi /etc/default/saslauthd
最初の変更点は起動に関して。
「START=no」から「START=yes」に変更しました。
# Should saslauthd run automatically on startup? (default: no)
START=yes
次に認証方法の選択です。
メカニズムの項目を「MECHANISMS="pam"」から「MECHANISMS="ldap"」に
変更しました。
# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam -- use PAM
# rimap -- use a remote IMAP server
# shadow -- use the local shadow password file
# sasldb -- use the local sasldb database file
# ldap -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="ldap"
これでsaslauthdの編集は終了です。
設定ファイルに書いてあるように、ldap認証を選択した場合には、ldap認証に関する
情報を「/etc/saslauthd.conf」に記載する必要があります。
/etc/saslauthd.confを新規に作成し、認証情報を記載します。
# vi /etc/saslauthd.conf
設定内容はこんな感じ。
ldap_servers: ldap://[ActiveDirectoryサーバーのIP]
ldap_default_domain: [ドメイン名]
ldap_search_base: DC=[ドメイン名1],DC=[ドメイン名2]
ldap_bind_dn: [ドメインユーザー]
ldap_bind_pw: [上記ドメインユーザーのパスワード]
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_filter: sAMAccountName=%u
ldap_password_attr: userPassword
ldap_timeout: 10
ldap_cache_ttl: 30
ldap_cache_mem: 32768
※ドメインユーザーやパスワードは、ldapサーバーに接続するために必要な情報で、
Subversionの認証がこのユーザーで行われるわけではありません。
具体的な設定例はこんな感じでしょうか。
ldap_servers: ldap://192.168.1.1
ldap_default_domain: sample.local
ldap_search_base: DC=sample,DC=local
ldap_bind_dn: admin@sample.local
ldap_bind_pw: 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_filter: sAMAccountName=%u
ldap_password_attr: userPassword
ldap_timeout: 10
ldap_cache_ttl: 30
ldap_cache_mem: 32768
編集が終わったら、saslのデーモンを起動します。
# /etc/init.d/saslauthd start
ちゃんと認証が行えるか、testsaslauthdコマンドでテストしておきます。
# testsaslauthd -u [ドメインユーザー] -p [パスワード]
認証が通過するとこんな表示になります。
# testsaslauthd -u testuser -p password
0: OK "Success."
わざとパスワードを間違えてみると、ちゃんと認証が失敗します。
# testsaslauthd -u testuser -p bad_password
0: NO "authentication failed"
これでSASLの設定は完了です。
svnserveの認証設定
svnserveの設定ファイルを編集して、認証にsaslを使用するように変更します。
/var/svnにリポジトリを作成したので、設定ファイルは「/var/svn/conf/svnserve.conf」
になります。
# vi /var/svn/conf/svnserve.conf
一旦、パスワードファイルによる認証を試していたので、generalにある
password-dbの項目を再度コメントアウトしました。
あわせて、認証を通過していないとリポジトリを表示しないよう
「anon-access = none」を指定しました。
[general]
anon-access = none
auth-access = write
# password-db = passwd
次に、saslの項目にある「use-sasl」のコメントを外し、有効とします。
[sasl]
use-sasl = true
これでsvnserveの設定は完了です。
svnserveとSASLの連携
このブログエントリで救われました。
SVN Authentication against a Microsoft Active Directory using svnserve sasl, ldap
/usr/lib/sasl2/svn.confを作成し、設定を記載します。
# vi /usr/lib/sasl2/svn.conf
設定内容は以下の通り。
pwcheck_method: saslauthd
auxprop_plugin: ldap
mech_list: PLAIN LOGIN
ldapdb_mech: PLAIN LOGIN
編集が終わったら、saslのデーモンを起動します。
# /etc/init.d/saslauthd start
svnserveの再起動
設定ファイルの変更内容を有効にするため、svnserveを再起動します。
この方法が正しいのかどうかわからないのですが・・・
# ps -aux
...
root 4217 0.0 0.1 9840 920 ? Ss 10:04 0:00 svnserve -d
root 4219 0.0 0.2 10392 1936 ? S 10:04 0:00 svnserve -d
root 4222 0.0 0.2 10628 2300 ? S 10:05 0:00 svnserve -d
root 4223 0.0 0.2 10392 1936 ? S 10:05 0:00 svnserve -d
...
svnserve -dになっているjobIDを全てkillしました。
# kill 4217
# kill 4219
# kill 4222
# kill 4223
そのあと、svnのリポジトリを作成したパス、例えば/var/svnに移動し、svnserve -dを実行。
# cd /var/svn
/var/svn# svnserve -d
これでSASLを使用しての認証となりました。
Eclipseプラグインからの接続を試す
ユーザー名、パスワードにActiveDirectoryに登録されている情報を入力します。
※ユーザー名にドメインの名称は含みません。

これであっさり接続できました。
※試行錯誤しながら設定したので、誤りがあるかもしれません・・・
- 関連記事
-
- MinGWで作成したDLLをJavaからJNI経由で呼び出す
- Debian svnserveの起動ファイルとEclipseの接続情報
- Subversionをsvnserveで公開し、ActiveDirectory(LDAP)認証と統合する
- Debianにsubversionをインストールし、Eclipseプラグイン経由で接続
- Vine Linux 6にLibreOfficeをインストールする
コメント