redmine 2.3中的open_id_authentication问题,包含配置文件数据

时间:2013-05-30 10:02:45

标签: ruby redmine

我使用open id认证插件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

以下是我的System 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:警告:PATH中的不安全世界可写dir / home / user,模式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 中间件ActionDispatch :: Static,Rack :: Lock,#,Rack :: Runtime,Rack :: MethodOverride,ActionDispatch :: RequestId,Rails :: Rack :: Logger,ActionDispatch :: ShowExceptions,ActionDispatch :: DebugExceptions,ActionDispatch :: RemoteIp ,ActionDispatch :: Reloader,ActionDispatch :: Callbacks,ActiveRecord :: ConnectionAdapters :: ConnectionManagement,ActiveRecord :: QueryCache,ActionDispatch :: Cookies,ActionDispatch :: Session :: CookieStore,ActionDispatch :: Flash,ActionDispatch :: ParamsParser,ActionDispatch :: Head,Rack :: ConditionalGet,Rack :: ETag,ActionDispatch :: BestStandardsSupport,OpenIdAuthentication 应用程序根目录/home/user/PROJECTS/redmine-2.3.1 环境发展 数据库适配器mysql2 数据库架构版本20130217094251

请帮助..

1 个答案:

答案 0 :(得分: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])

它会起作用。