先安裝完LAMP 之後,執行下面:
First of all, install the auth-mysql Apache module:
$ aptitude install libapache2-mod-auth-mysql
$ a2enmod auth_mysql
$ /etc/init.d/apache2 restart

設定/etc/apache2/mods-available/dav_svn.conf
   AuthType Basic
            AuthName "your auth name"
   AuthBasicAuthoritative Off

            AuthMySQL On
            AuthMySQL_Authoritative On
   #MySQL DB
            AuthMySQL_Host 192.168.1.47
            AuthMySQL_DB "bitnami_redmine"
            AuthMySQL_User "bitnami"
            AuthMySQL_Password "ebcacda60e"
            #User Tables
            AuthMySQL_Password_Table "users"
            AuthMySQL_Username_Field "login"
            AuthMySQL_Password_Field "hashed_password"
            AuthMySQL_Encryption_Types SHA1Sum
            AuthMySQL_Empty_Passwords off
            #Group Tables
            #Auth_MySQL_Group_Table "users, users_roles"
            #Auth_MySQL_Group_Field users_roles.rid
            #WHERE Clauses
            AuthMySQL_Password_Clause " AND status = '1' and type = 'User'"

Redmine的修改
由於redmine2.1.2版本修改了password的加密方式 SHA1(salt + SHA1(password))
這就導致我們的mod_auth_mysql 沒有辦法直接工作
官方論壇找到兩種解決方案
1) Patch mod_auth_mysql to apply salt in the same manner as redmine.
2) Patch redmine to store 「unsalted」 hashed passwords alongside the currently salted ones.
http://www.redmine.org/boards/2/topics/24386

這裡第二種方案,去改redmine密碼加密的方式
line 245
User.hash_password(「#{salt}#{User.hash_password clear_password}」) == hashed_password
change to
User.hash_password(clear_password) == hashed_password

line 254
self.hashed_password = User.hash_password(「#{salt}#{User.hash_password clear_password}」)
change to
self.hashed_password = User.hash_password(clear_password)

line 592
hashed_password = User.hash_password(「#{salt}#{user.hashed_password}」)
change to
hashed_password = user.hashed_password
這樣mod_auth_mysql就能直接通過sha1加密匹配hashed_passsword字段了
這樣我們就實現了redmine subversion 的用戶單點登錄

參考來源:
http://ailoo.net/2009/03/authenticate-apache-against-redmine-with-authmysql/
http://www.oulan.com/topics/tag/redmine
https://drupal.org/node/441876
http://www.apachefriends.org/f/viewtopic.php?p=92667
http://www.redmine.org/projects/redmine/wiki/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl
http://www.pigo.idv.tw/archives/851#more-851

創作者介紹
創作者 Empty 的頭像
Empty

虎搞瞎搞

Empty 發表在 痞客邦 留言(0) 人氣()