让 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,如果你真的不能用再安装试试看)

安装的方式就是下载,然后解压缩到redminevendorplugins的数据夹中 ( 可能会因为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