LoginSignup
7
9

More than 5 years have passed since last update.

Apache2経由でSVNアクセス時にLDAPで認証し、認証済みユーザとして任意のLDAP属性をSVNに渡す

Last updated at Posted at 2013-08-18

環境

  • CentOS 6.4
  • Subversion 1.6.11
  • Apache2 2.2.15 (2.2.3以下では、AuthLDAPRemoteUserAttribute ディレクティブ未実装)
  • OpenDJ 2.6.0
  • Oracle JDK 1.7.25

概要

  • mod_authnz_ldapを使用
  • LDAPに存在するユーザでBASIC認証を実施
  • SVNから送るコミットメールに乗せるコミットユーザ名をいい感じにする 具体的には、ApacheのREMOTE_USER環境変数を任意のLDAP属性にする

関連文献

Apache Module mod_authnz_ldap
http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapremoteuserattribute

事前準備

ミドルウェアセットアップ

httpdとsubversionのインストール

yum -y install httpd subversion mod_dav_svn

javaの導入は下記に譲って省略。
http://java.com/ja/download/help/index_installing.xml

OpenDJの導入も本稿の本意ではないので省略。
以降の記述に関わる部分は、
* ベース DN: dc=nt67,dc=org
* セットアップディレクトリは /opt/opendj/

OpenDJの設定内容
/opt/opendj# /opt/opendj/bin/status


>>>> OpenDJ LDAP 接続パラメータを指定します

管理者ユーザーのバインド DN [cn=Directory Manager]: cn=admin

ユーザー 'cn=admin' のパスワード: 

          --- サーバーの状態 ---
サーバーの稼動状態:   起動中
開いている接続数:    1

          --- サーバーの詳細 ---
ホスト名:        ldap.nt67
管理ユーザー:      cn=admin
インストールパス:    /opt/opendj
バージョン:       OpenDJ 2.6.0
Java のバージョン: 1.7.0_25
管理コネクタ:      ポート 5444 (LDAPS)

          --- 接続ハンドラ ---
アドレス:ポート     : プロトコル : 状態
-------------:-------:---
--           : LDIF  : 無効
0.0.0.0:161  : SNMP  : 無効
0.0.0.0:636  : LDAPS : 無効
0.0.0.0:1389 : LDAP  : 有効
0.0.0.0:1689 : JMX   : 無効
0.0.0.0:8080 : HTTP  : 無効

          --- データソース ---
ベース DN:    dc=nt67,dc=org
バックエンド ID: userRoot
エントリ:      1
レプリケーション:  

LDAPのエントリ情報

LDAPのディレクトリ設定情報

entry.ldif

dn: dc=nt67,dc=org
objectClass: dcObject
objectClass: organization
dc: nt67
o: nt67.org

dn: ou=User,dc=nt67,dc=org
objectClass: organizationalUnit
ou: User

dn: cn=user001,ou=User,dc=nt67,dc=org
objectClass: person
objectClass: inetOrgPerson
cn: user001
sn: user001_sn
userPassword: user001
mail: user001@nt67.org

dn: cn=user002,ou=User,dc=nt67,dc=org
objectClass: person
objectClass: inetOrgPerson
cn: user002
sn: user002_sn
userPassword: user002
mail: user002@nt67.org

dn: cn=user003,ou=User,dc=nt67,dc=org
objectClass: person
objectClass: inetOrgPerson
cn: user003
sn: user003_sn
userPassword: user003
mail: user003@nt67.org

SVN設定

/etc/httpd/conf.d/subversion.conf

<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn

   AuthType Basic
   AuthBasicProvider ldap 
   AuthzLDAPAuthoritative off
   # 認証済みユーザ名として mail属性を設定する
   AuthLDAPRemoteUserAttribute mail
   AuthName "Auth for nt67.org"
   # 認証用文字列として cn を、あわせてmail属性を引っ張ってくる。
   AuthLDAPUrl ldap://ldap.nt67:1389/ou=User,dc=nt67,dc=org?cn,mail
   Require valid-user
</Location>

結果

コミットするときの認証として、cn属性のユーザ名を使う。
コミットログには mail 属性が設定される。

commit

svn commit -m "first commit" --username user001 --password user001

svn log
------------------------------------------------------------------------
r1 | user001@nt67.org | 2013-08-17 23:09:13 -0700 (土, 17  8月 2013) | 1 line

first commit
------------------------------------------------------------------------

7
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9