プロジェクト

全般

プロフィール

SubversionにRedmineの認証を連携する » 履歴 » バージョン 4

Hidehisa Matsutani, 2015/11/27 23:45

1 1 Hidehisa Matsutani
h1. SubversionにRedmineの認証を連携する
2
3
SubversionとRedmineの認証連携ができると、Redmineのユーザ/パスワードでSubversionにコミットできます。
4
いろいろと試行錯誤した結果、無事連携できたので、ノウハウをまとめておきます。
5
6
h2. 前提条件
7
8
* Bitnami Redmine を利用
9
* サーバはCentOS
10
* Bitnamiのインストールフォルダは/opt/redmine-3.0.3-0
11
12
13
h2. mod_auth_mysqlのインストール
14
15
<pre>
16
    # yum install mod_auth_mysql
17
</pre>
18
19
h2. Redmine に同梱されている Redmine.pm を Perl の実行パスへシンボリックリンク
20
21
<pre>
22
    # mkdir -p /opt/redmine-3.0.3-0/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi/Apache/Authn
23
    # ln -s /opt/redmine-3.0.3-0/apps/redmine/htdocs/extra/svn/Redmine.pm /opt/redmine-3.0.3-0/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi/Apache/Authn
24
</pre>
25
26
h2. デフォルトの権限設定を記述
27
28
<pre>
29
    # vi /opt/redmine-3.0.3-0/repos/svnauthz
30
</pre>
31
32
<pre>
33
# common settings
34
[/]
35
admin = rw
36
* = rw
37
guest = r
38
</pre>
39
40
h2. httpd.confに以下を追加
41
42
<pre>
43
    # vi /opt/redmine-3.0.3-0/apache2/conf/httpd.conf
44
</pre>
45
46
<pre>
47
Include conf/extra/httpd-svn.conf
48
</pre>
49
50
51
h2. mod_auth_mysql.so の作り直し
52
53 3 Hidehisa Matsutani
h3. BitNami Redmine Stack に同梱されている Apache 2.4 では API がいくつか変更されたらしいので、パッチをあてます
54 1 Hidehisa Matsutani
55
https://osdn.jp/projects/sfnet_modauthmysql/
56
から、mod_auth_mysql-3.0.0.tar.gzをダウンロードします。
57
58
http://sourceforge.net/p/modauthmysql/patches/13/
59
のパッチを当てて、mod_auth_mysql.so を作り直します。
60
この作業では gcc がインストールされている必要があります。
61
62
<pre>
63
    # tar xzvf mod_auth_mysql-3.0.0.tar.gz
64
    # patch -p0 < mod_auth_mysql_3.0.0_patch_apache2.4.diff
65
    # cd mod_auth_mysql-3.0.0/
66
    # /opt/redmine-3.0.3-0/use_redmine
67
    # apxs -c -L/opt/redmine-3.0.3-0/mysql/lib -I/opt/redmine-3.0.3-0/mysql/include -lmysqlclient -lm -lz mod_auth_mysql.c
68
    # apxs -i mod_auth_mysql.la
69
</pre>
70
71
h3. ユーザテーブルにsaltが追加されたが、mod_auth_mysqlがRedmineのsaltの掛け方に対応していないので、パッチをあてます
72
73
(参考) http://d.hatena.ne.jp/vmi/20111102/p1 
74
パッチは http://www.redmine.org/boards/2/topics/24386?r=25722#message-25722 からダウンロードします。
75
76
<pre>
77
    # patch -p0 < mod_auth_mysql-3.0.0-redmine.patch
78
    # cd mod_auth_mysql-3.0.0/
79
    # /opt/redmine-3.0.3-0/use_redmine
80
    # apxs -c -L/opt/redmine-3.0.3-0/mysql/lib -I/opt/redmine-3.0.3-0/mysql/include -lmysqlclient -lm -lz mod_auth_mysql.c
81
    # apxs -i mod_auth_mysql.la
82
</pre>
83
84 2 Hidehisa Matsutani
h2. httpd-svn.confを作成
85 1 Hidehisa Matsutani
86
* Subversion に WebDAV 経由でアクセスできるようにします
87
88
* access_handler にバグがあるらしいのでコメントアウトしています。
89
(参考) http://sc1h5r.cswiki.jp/index.php?Subversion%E3%81%AEApache%E7%B5%8C%E7%94%B1%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%81%AE%E8%A8%AD%E5%AE%9A
90
91
* http://d.hatena.ne.jp/vmi/20111102/p1
92
によりユーザテーブルにsaltが追加されたことの設定を追加しています。
93
94
* {DB_password}{port}は適宜インストール環境に合わせて読み替えてください。
95
96
<pre>
97
    # vi /opt/redmine-3.0.3-0/apache2/conf/extra/httpd-svn.conf
98
</pre>
99
100
<pre>
101
LoadModule perl_module modules/mod_perl.so
102
PerlLoadModule Apache::Authn::Redmine
103
104
<Location /svn>
105
  DAV svn
106
  SVNParentPath "/var/svn"
107
  AuthType Basic
108
  AuthName Subversion
109
  Require valid-user
110
  AuthUserFile /dev/null
111
  AuthBasicAuthoritative Off
112
  AuthMySQLAuthoritative On
113
# my.cnfの設定に合わせて変更
114
  AuthMySQLSocket /opt/redmine-3.0.3-0/mysql/tmp/mysql.sock
115
# Redmineのdatabase.ymlの設定に合わせて変更
116
  AuthMySQLHost localhost
117
  AuthMySQLUser bitnami
118
  AuthMySQLPassword {DB_password}
119
  AuthMySQLDB bitnami_redmine
120
### Redmineのテーブルとの紐付け
121
# Redmineのユーザテーブル
122
  AuthMySQLNoPasswd Off
123
  AuthMySQLUserTable users
124
  AuthMySQLNameField login
125
  AuthMySQLPasswordField hashed_password
126
  AuthMySQLSaltField salt
127
  AuthMySQLPwEncryption sha1-rm
128
# グループの設定。プロジェクト識別子をグループとして扱う
129
  AuthMySQLGroupTable "users, members, projects"
130
  AuthMySQLGroupCondition "users.id = members.user_id and projects.id = members.project_id"
131
  AuthMySQLGroupField "projects.identifier"
132
133
  AuthzSVNAccessFile /opt/redmine-3.0.3-0/repos/svnauthz
134
  #PerlAccessHandler Apache::Authn::Redmine::access_handler
135
  PerlAuthenHandler Apache::Authn::Redmine::authen_handler
136
137
  RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost:{port};mysql_socket=/opt/redmine-3.0.3-0/mysql/tmp/mysql.sock"
138
  RedmineDbUser "bitnami"
139
  RedmineDbPass "{DB_password}"
140
</Location>
141
142
</pre>
143
144
h2. Redmineを再起動します。
145
146
<pre>
147
# /opt/redmine-3.0.3-0/ctlscript.sh restart
148
</pre>
149
150 4 Hidehisa Matsutani
h2. Redmineのユーザ/パスワードでSubversionのコミットができれば成功