讓 Redmine支援 Google 帳號登入 (Google,Yahoo…)

讓 Redmine支援 Google 帳號登入 (Google,Yahoo…)

 

啟用OpenID支援

redmine版本:1.2.1.stable (使用bitnami安裝版)

首先你必須要先安裝兩個函式庫,進入指令環境裝完後重啟 redmine,也可以使用 gem list ruby-openid 來查看是否安裝成功。

gem install ruby-openid
gem install ruby-openid-apps-discovery 

 

 

image

 

進入Redmine管理後臺=>網站設定=>設定,將"允許OpenID登入與註冊打勾"

(如果你沒有先安裝上面的函式庫,核取方塊會是灰色的)

 

image

安裝 Plugin

接下來下載兩個套件來支援登入畫面可以選擇要登入的帳號類別

http://www.redmine.org/plugins/openid-selector

http://www.redmine.org/plugins/openid_fix (說實在的這個裝了還是有錯誤,後來我就移除掉了,還是能 work,如果你真的不能用再安裝試試看)

 

安裝的方式就是下載,然後解壓縮到redmine\vendor\plugins的資料夾中 ( 可能會因為redmine版本差異,而路徑有所差異)

然後下指令

rake db:migrate_plugins RAILS_ENV=production

 

 

 

安裝Patch檔

接下來這個是重點,我重複安裝了上面的步驟一直無法成功,會出現500錯誤,查看log會發現下面的錯誤

Processing AccountController#login (for 114.xxx.153.xxx at 2012-07-27 12:16:35) [POST]
Parameters: {"openid.mode"=>"id_res", "openid.op_endpoint"=>"https://www.google.com/accounts/o8/ud", "openid.return_to"=>"http://xxx.xxx.tw/redmine/login?_method=post&open_id_complete=1", "openid.sig"=>"5ZRLVIA=", "openid.response_nonce"=>"2012-07-27T04:16:29ZDhGx-h6t8pNk-A", "openid.ns"=>"http://specs.openid.net/auth/2.0", "action"=>"login", "_method"=>"post", "openid.identity"=>"https://www.google.com/accounts/o8/id?id=AItOawkTgfeW_a3q8Q0xkPXtyzHuM-c8Z-c4xBI", "openid.assoc_handle"=>"AMlYA9XXuUSEIrX0id.signed"=>"op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle", "controller"=>"account", "open_id_complete"=>"1", "openid.claimed_id"=>"https://www.google.com/accounts/o8/id?id=AI4xBI"}
No pre-discovered information supplied
Performing discovery on https://www.google.com/accounts/o8/id?id=AItOawkTgfeW_ac4xBI
WARNING: making https request to https://www.google.com/accounts/o8/id?id=AItfseOawkfzHuM-c8Z-c4xBI without verifying server certificate; no CA path was specified.
Redirected to http://xxx.xxx.tw:81/redmine/my/page
Completed in 200ms (DB: 53) | 302 Found [http://xxx.xxx.tw/redmine/login?_method=post&open_id_complete=1&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%p_endpoint=https%3A%oogle.com%2Facse_nonce=2012-07-27T04%3enid.return_to=http%3A%2F%2Fxxexm.xxx.tw%3A81%2Fredmine%2Flogin%3F_method%3Dpost%26open_id_complete%3D1&openid.assoc_handle=AMlYA9XXuUSEIrX0M4Mn1n-nzc_handle&openid.sig=5ZRLBQIIy=https%3A%2F%2Fwww.google.wkTgfeW_a3q8Q0ximed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkTgfeW_a3q8]

 

 

找了很多資料,最後終於找到一個使用者自己回報一個patch,但是也無法確認,但居然被我矇到了…

把它下載後,放到config/initializers/下,重啟 redmine,一切就正常了。

http://www.redmine.org/boards/2/topics/25466

 

完成

這時你的登入頁面應該會長成這樣

image

附註

如果你已經有既有的帳戶,該如何結合呢?

你可以先用Openid註冊一個帳號,然後進去檢視帳戶的資料,你會發現帳戶的OpenID欄位多了個連結資料,

將它複製到舊的帳號的Openid欄位上即可。(記得把剛剛新增的帳號刪除)

image