0

我有带有开放身份验证插件的 redmine 2.3。代码看起来像

def login
    domain = GoogleAppsAuthSource.find params[:id]
    oid = "https://www.google.com/accounts/o8/site-xrds?hd=#{domain.name}"
     attributes = [AX_EMAIL, AX_FIRST, AX_LAST]
    authenticate_with_open_id(oid, :return_to => request.url, :required => attributes) do |result, identity_url, profile_data|
      if result.successful?

        email = profile_data[AX_EMAIL].first
        first = profile_data[AX_FIRST].first
 end
end 

此处从服务器返回的配置文件数据始终为空白,这适用于旧版本的 redemine,例如 1.3。进入控制台的确切错误是,

ArgumentError (http://axschema.org/contact/email/ is not a defined simple registration field):
  lib/plugins/open_id_authentication/lib/open_id_authentication.rb:145:in `complete_open_id_authentication'
  lib/plugins/open_id_authentication/lib/open_id_authentication.rb:121:in `authenticate_with_open_id'

当我尝试打印配置文件数据对象时

############### PROFILE DATA ###############
--- !ruby/object:OpenID::SReg::Response
ns_alias: sreg
data: {}

这是我的Redmine环境

环境:Redmine 版本 2.3.1.stable Ruby 版本 1.9.3 (i686-linux) Rails 版本 3.2.13 环境开发 数据库适配器 Mysql2 Redmine 插件:google_apps 0.1 redmine_meeting_room_calendar 0.0.1

以下是我的系统 Rails 环境 user@user-desktop:~/PROJECTS/redmine-2.3.1$ rake about /home/user/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.5/ lib/bundler/runtime.rb:216: 警告: Insecure world writable dir /home/user in PATH, mode 040777 关于应用程序的环境 Ruby 1.9.3 (i686-linux) RubyGems 1.8.24 机架版本 1.4 Rails 3.2 .13 Active Record 版本 3.2.13 Action Pack 版本 3.2.13 Active Resource 版本 3.2.13 Action Mailer 版本 3.2.13 Active Support 版本 3.2.13 Middleware ActionDispatch::Static, Rack::Lock, #, Rack::Runtime, Rack::MethodOverride、ActionDispatch::RequestId、Rails::Rack::Logger、ActionDispatch::ShowExceptions、ActionDispatch::DebugExceptions、ActionDispatch::RemoteIp、ActionDispatch::重新加载器、ActionDispatch::Callbacks、ActiveRecord::ConnectionAdapters::ConnectionManagement、ActiveRecord::QueryCache、ActionDispatch::Cookies、ActionDispatch::Session::CookieStore、ActionDispatch::Flash、ActionDispatch::ParamsParser、ActionDispatch::Head、机架: :ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport, OpenIdAuthentication Application root /home/user/PROJECTS/redmine-2.3.1 环境开发 数据库适配器mysql2 数据库模式版本20130217094251OpenIdAuthentication Application root /home/user/PROJECTS/redmine-2.3.1 环境开发 数据库适配器 mysql2 数据库模式版本 20130217094251OpenIdAuthentication Application root /home/user/PROJECTS/redmine-2.3.1 环境开发 数据库适配器 mysql2 数据库模式版本 20130217094251

请帮忙 ..

4

1 回答 1

0

请像这样更改 google_apps 控制器 AX_* 代码

 AX_EMAIL = 'http://schema.openid.net/contact/email'
  AX_FIRST = 'http://schema.openid.net/contact/fullname/'
  AX_LAST = 'http://schema.openid.net/contact/last/'

并像这样重新初始化 profile_data:

 authenticate_with_open_id(oid, :return_to => request.url,:required => attributes ) do |result, identity_url, profile_data|
      if result.successful?
        profile_data = OpenID::AX::FetchResponse.from_success_response(request.env[Rack::OpenID::RESPONSE])

它会起作用的。

于 2013-06-04T08:10:31.137 回答