SubversionByRedmine - glad2121/bitnami-redmine-ext GitHub Wiki
Subversion の認証・認可を Redmine のアカウントで制御できるように設定します。
Apache の認証・認可に MySQL のデータベースを使用するためのモジュールです。
最初に ALMinium に同梱されているパッケージを使用してみました。
[root@bitnami tmp]# mkdir mod_auth_mysql
[root@bitnami tmp]# cd mod_auth_mysql/
[root@bitnami mod_auth_mysql]# rpm2cpio ../mod_auth_mysql-3.0.0-11.el6.1.redmine.x86_64.rpm | cpio -idv
./etc/httpd/conf.d/auth_mysql.conf
./usr/lib64/httpd/modules/mod_auth_mysql.so
./usr/share/doc/mod_auth_mysql-3.0.0
./usr/share/doc/mod_auth_mysql-3.0.0/CHANGES
./usr/share/doc/mod_auth_mysql-3.0.0/CONFIGURE
./usr/share/doc/mod_auth_mysql-3.0.0/LICENSE
./usr/share/doc/mod_auth_mysql-3.0.0/README
103 blocks
[root@bitnami mod_auth_mysql]# cp -piv usr/lib64/httpd/modules/mod_auth_mysql.so /opt/bitnami/apache2/modules/
`usr/lib64/httpd/modules/mod_auth_mysql.so' -> `/opt/bitnami/apache2/modules/mod_auth_mysql.so'
[root@bitnami mod_auth_mysql]# cp -piv etc/httpd/conf.d/auth_mysql.conf /opt/bitnami/apache2/conf/extra/
`etc/httpd/conf.d/auth_mysql.conf' -> `/opt/bitnami/apache2/conf/extra/auth_mysql.conf'
Redmine に同梱されている Redmine.pm を Perl の実行パスへコピーします。
[root@bitnami tmp]# mkdir /opt/bitnami/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi/Apache/Authn
[root@bitnami tmp]# cp /opt/bitnami/apps/redmine/htdocs/extra/svn/Redmine.pm
/opt/bitnami/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi/Apache/Authn/
/opt/bitnami/repos/svnauthz
を作成し、デフォルトの権限設定を記述します。
# common settings
[/]
admin = rw
* = rw
guest = r
/opt/bitnami/apache2/conf/extra/httpd-vcs.conf
を作成し、Subversion に WebDAV 経由でアクセスできるようにします。
データベースのパスワードは /opt/bitnami/apps/redmine/htdocs/config/database.yml
を参照してください。
LoadModule perl_module modules/mod_perl.so
PerlLoadModule Apache::Authn::Redmine
# Subversion settings
<Location /svn>
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
DAV svn
SVNParentPath /opt/bitnami/repos/svn
SVNListParentPath on
AuthzSVNAccessFile /opt/bitnami/repos/svnauthz
AuthType Basic
AuthName Subversion
# for Redmine Authentication
RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost;mysql_socket=/opt/bitnami/mysql/tmp/mysql.sock"
RedmineDbUser "bitnami"
RedmineDbPass "{password}"
Require valid-user
</Location>
# Git settings
SetEnv GIT_PROJECT_ROOT /opt/bitnami/repos/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /opt/bitnami/git/libexec/git-core/git-http-backend/
<Location /git>
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
AuthType Basic
AuthName Git
# for Redmine Authentication
RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost;mysql_socket=/opt/bitnami/mysql/tmp/mysql.sock"
RedmineDbUser "bitnami"
RedmineDbPass "{password}"
RedmineGitSmartHttp yes
Require valid-user
</Location>
/opt/bitnami/apache2/conf/httpd.conf
の最後に以下の設定を追加します。
Include conf/extra/auth_mysql.conf
Include conf/extra/httpd-vcs.conf
Apache(Redmine)を再起動します。
[root@bitnami tmp]# service bitnami-redmine restart apache
httpd: Syntax error on line 558 of /opt/bitnami/apache2/conf/httpd.conf:
Syntax error on line 6 of /opt/bitnami/apache2/conf/extra/auth_mysql.conf:
Cannot load modules/mod_auth_mysql.so into server:
/opt/bitnami/apache2/modules/mod_auth_mysql.so: undefined symbol: ap_requires
apache config test fails, aborting
httpd: Syntax error on line 558 of /opt/bitnami/apache2/conf/httpd.conf:
Syntax error on line 6 of /opt/bitnami/apache2/conf/extra/auth_mysql.conf:
Cannot load modules/mod_auth_mysql.so into server:
/opt/bitnami/apache2/modules/mod_auth_mysql.so: undefined symbol: ap_requires
apache config test fails, aborting
BitNami Redmine Stack に同梱されている Apache 2.4 では API がいくつか変更されたらしく、エラーが発生します。
http://sourceforge.net/p/modauthmysql/patches/13/
のパッチを当てて、mod_auth_mysql.so を作り直します。
この作業では gcc がインストールされている必要があります。
[root@bitnami tmp]# tar xzvf mod_auth_mysql-3.0.0.tar.gz
mod_auth_mysql-3.0.0/BUILD
mod_auth_mysql-3.0.0/CHANGES
mod_auth_mysql-3.0.0/CONFIGURE
mod_auth_mysql-3.0.0/README
mod_auth_mysql-3.0.0/mod_auth_mysql.c
[root@bitnami tmp]# patch -p0 < mod_auth_mysql_3.0.0_patch_apache2.4.diff
patching file mod_auth_mysql-3.0.0/mod_auth_mysql.c
[root@bitnami tmp]# cd mod_auth_mysql
[root@bitnami mod_auth_mysql]# cd ..
[root@bitnami tmp]# cd mod_auth_mysql-3.0.0/
[root@bitnami mod_auth_mysql-3.0.0]# /opt/bitnami/use_redmine
bash-4.1# apxs -c -L/opt/bitnami/mysql/lib -I/opt/bitnami/mysql/include
-lmysqlclient -lm -lz mod_auth_mysql.c <- 1行で入力
/opt/bitnami/common/build-1/libtool --silent --mode=compile gcc -std=gnu99 -prefer-pic
-I/opt/bitnami/common/include -fPIC -m64
-I/bitnami/rubystack-linux-x64/output/ImageMagick/include/ImageMagick
-I/bitnami/rubystack-linux-x64/output/ImageMagick/include/ImageMagick
-DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread
-I/opt/bitnami/apache2/include
-I/opt/bitnami/common/include/apr-1
-I/opt/bitnami/common/include/apr-1
-I/opt/bitnami/common/include
-I/opt/bitnami/mysql/include
-c -o mod_auth_mysql.lo mod_auth_mysql.c && touch mod_auth_mysql.slo
/opt/bitnami/common/build-1/libtool --silent --mode=link gcc -std=gnu99
-L/opt/bitnami/common/lib -liconv -o mod_auth_mysql.la
-L/opt/bitnami/mysql/lib -lmysqlclient -lm -lz
-rpath /opt/bitnami/apache2/modules -module -avoid-version mod_auth_mysql.lo
bash-4.1# apxs -i mod_auth_mysql.la
/opt/bitnami/apache2/build/instdso.sh
SH_LIBTOOL='/opt/bitnami/common/build-1/libtool'
mod_auth_mysql.la /opt/bitnami/apache2/modules
/opt/bitnami/common/build-1/libtool --mode=install install mod_auth_mysql.la /opt/bitnami/apache2/modules/
libtool: install: install .libs/mod_auth_mysql.so
/opt/bitnami/apache2/modules/mod_auth_mysql.so
libtool: install: install .libs/mod_auth_mysql.lai
/opt/bitnami/apache2/modules/mod_auth_mysql.la
libtool: install: install .libs/mod_auth_mysql.a
/opt/bitnami/apache2/modules/mod_auth_mysql.a
libtool: install: chmod 644 /opt/bitnami/apache2/modules/mod_auth_mysql.a
libtool: install: ranlib /opt/bitnami/apache2/modules/mod_auth_mysql.a
libtool: finish: PATH="/opt/bitnami/perl/bin:/opt/bitnami/git/bin:
/opt/bitnami/sqlite/bin:/opt/bitnami/ruby/bin:/opt/bitnami/subversion/bin:
/opt/bitnami/php/bin:/opt/bitnami/mysql/bin:/opt/bitnami/apache2/bin:
/opt/bitnami/common/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:
/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/bitnami/bin:/sbin"
ldconfig -n /opt/bitnami/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
/opt/bitnami/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /opt/bitnami/apache2/modules/mod_auth_mysql.so
Apache(Redmine)を再起動します。
[root@bitnami tmp]# service bitnami-redmine restart apacheSyntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd stopped
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80
ブラウザで http://{hostname}/svn/{reponame} にアクセスすると、エラーになります。 ログで確認すると、以下のエラーメッセージが出力されています。
[Sun May 25 01:13:28.666709 2014] [core:error] [pid 9780] [client 192.168.xx.xx:xxxxx]
AH00027: No authentication done but request not allowed without authentication for /svn/sandbox/.
Authentication not configured?, referer: http://localhost/projects/sandbox
http://sc1h5r.cswiki.jp/index.php?SubversionのApache経由アクセスの設定
によると、access_handler にバグがあるらしいのでコメントアウトします。
LoadModule perl_module modules/mod_perl.so
PerlLoadModule Apache::Authn::Redmine
# Subversion settings
<Location /svn>
# PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
DAV svn
SVNParentPath /opt/bitnami/repos/svn
SVNListParentPath on
AuthzSVNAccessFile /opt/bitnami/repos/svnauthz
AuthType Basic
AuthName Subversion
# for Redmine Authentication
RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost;mysql_socket=/opt/bitnami/mysql/tmp/mysql.sock"
RedmineDbUser "bitnami"
RedmineDbPass "{password}"
Require valid-user
</Location>
# Git settings
SetEnv GIT_PROJECT_ROOT /opt/bitnami/repos/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /opt/bitnami/git/libexec/git-core/git-http-backend/
<Location /git>
# PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
AuthType Basic
AuthName Git
# for Redmine Authentication
RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost;mysql_socket=/opt/bitnami/mysql/tmp/mysql.sock"
RedmineDbUser "bitnami"
RedmineDbPass "{password}"
RedmineGitSmartHttp yes
Require valid-user
</Location>
Apache(Redmine)を再起動して、正常に稼働していることを確認します。
もともと BitNami Redmine Stack で起動している svnserve を停止し、スクリプトの実行権限を外して起動しないようにします。
[root@bitnami tmp]# service bitnami-redmine stop
/opt/bitnami/subversion/scripts/ctl.sh : subversion stopped
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd stopped
140525 01:51:30 mysqld_safe mysqld from pid file /opt/bitnami/mysql/data/mysqld.pid ended
/opt/bitnami/mysql/scripts/ctl.sh : mysql stopped
[root@bitnami tmp]# chmod -x /opt/bitnami/subversion/scripts/ctl.sh
[root@bitnami tmp]# service bitnami-redmine start
140525 01:51:58 mysqld_safe Logging to '/opt/bitnami/mysql/data/mysqld.log'.
140525 01:51:58 mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data
/opt/bitnami/mysql/scripts/ctl.sh : mysql started at port 3306
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80
- BitNami Redmine Documentation
http://wiki.bitnami.com/Applications/BitNami_Redmine - ALMinium
https://github.com/alminium/alminium - SubversionのApache経由アクセスの設定 - Memorandum
http://sc1h5r.cswiki.jp/index.php?SubversionのApache経由アクセスの設定