2012-03-06 90 views
0

我用紅寶石的OpenID身份驗證允許使用OpenIDRuby on Rails的採用OpenID身份驗證例外

當我用下面的軌道紅寶石1.8使用:

ii rails             2.3.5-1.2+squeeze1   MVC ruby based framework geared for web application development 
ii rails-ruby1.8           2.3.5-1.2+squeeze1   MVC ruby based framework geared for web application development 
ii rake             0.8.7-2      a ruby build program 
ii ruby             4.5       An interpreter of object-oriented scripting language Ruby 
ii ruby1.8            1.8.7.302-2squeeze1   Interpreter of object-oriented scripting language Ruby 1.8 
ii ruby1.8-dev           1.8.7.302-2squeeze1   Header files for compiling extension modules for the Ruby 1.8 
ii rubygems            1.3.7-3      package management framework for Ruby libraries/applications 
ii rubygems1.8           1.3.7-3      package management framework for Ruby libraries/applications 

一切工作正常。

但是當我更新爲:從OpenID提供權威性SUCC後

ruby 1.9.3p125 (2012-02-16) [x86_64-linux] 
Rails 3.2.2 
1.8.11 

,並返回到我的網頁,發生異常:

驗證失敗:意外的參數(不是的return_to):'控制器'=無)

我嘗試讀idres.rb發現的:

@message.get_args(BARE_NS).each_pair do |bare_key, bare_val| 
    rt_val = return_to_parsed_query[bare_key] 
    if not return_to_parsed_query.has_key? bare_key 
     # This may be caused by your web framework throwing extra 
     # entries in to your parameters hash that were not GET or 
     # POST parameters. For example, Rails has been known to 
     # add "controller" and "action" keys; another server adds 
     # at least a "format" key. 
     raise ProtocolError, ("Unexpected parameter (not on return_to): "\ 
      "'#{bare_key}'=#{rt_val.inspect})") 
     end 
     if rt_val != bare_val 
      raise ProtocolError, ("Parameter '#{bare_key}' value "\ 
       "#{bare_val.inspect} does not match "\ 
       "return_to's value #{rt_val.inspect}") 

我是一個新手紅寶石。如何解決這個問題?感謝以下

日誌非常多:

Started GET "/consumer/start" for 218.107.55.254 at 2012-03-06 18:12:26 +0800 Processing by ConsumerController#start as HTML Redirected to http://pip.verisignlabs.com/server?openid.assoc_handle=e25c42b0-6774-11e1-9fdb-8f540be9bc3e&openid.claimed_id=http%3A%2F%2Fstutiredboy.pip.verisignlabs.com%2F&openid.identity=http%3A%2F%2Fstutiredboy.pip.verisignlabs.com%2F&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&openid.realm=http%3A%2F%2F114.113.197.25%3A3000%2Fconsumer&openid.return_to=http%3A%2F%2F114.113.197.25%3A3000%2Fconsumer%2Fcomplete%3Fdid_sreg%3Dy&openid.sreg.required=email%2Cnickname%2Cfullname Completed 302 Found in 4914ms (ActiveRecord: 0.0ms) 


Started GET "/consumer/complete?did_sreg=y&openid.sreg.fullname=tiredboy&openid.assoc_handle=e25c42b0-6774-11e1-9fdb-8f540be9bc3e&openid.response_nonce=2012-03-06T10%3A12%3A32ZzI16RQ%3D%3D&openid.sreg.email=stumyreg%40gmail.com&openid.sreg.nickname=tiredboy&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=http%3A%2F%2Fpip.verisignlabs.com%2Fserver&openid.pape.auth_policies=http%3A%2F%2Fschemas.openid.net%2Fpape%2Fpolicies%2F2007%2F06%2Fnone&openid.claimed_id=http%3A%2F%2Fstutiredboy.pip.verisignlabs.com%2F&openid.sig=yNsdpak%2FyNi%2BcFp0oxmjtL3DmoY%3D&openid.identity=http%3A%2F%2Fstutiredboy.pip.verisignlabs.com%2F&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.auth_time=2012-03-06T07%3A16%3A09Z&openid.signed=assoc_handle%2Cidentity%2Cresponse_nonce%2Creturn_to%2Cclaimed_id%2Cop_endpoint%2Cns.sreg%2Csreg.nickname%2Csreg.email%2Csreg.fullname%2Cns.pape%2Cpape.auth_policies%2Cpape.auth_time&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&openid.return_to=http%3A%2F%2F114.113.197.25%3A3000%2Fconsumer%2Fcomplete%3Fdid_sreg%3Dy" for 218.107.55.254 at 2012-03-06 18:12:32 +0800 Processing by ConsumerController#complete as HTML Parameters: {"did_sreg"=>"y", "openid.sreg.fullname"=>"tiredboy", "openid.assoc_handle"=>"e25c42b0-6774-11e1-9fdb-8f540be9bc3e", "openid.response_nonce"=>"2012-03-06T10:12:32ZzI16RQ==", "openid.sreg.email"=>"[email protected]", "openid.sreg.nickname"=>"tiredboy", "openid.ns"=>"http://specs.openid.net/auth/2.0", "openid.mode"=>"id_res", "openid.op_endpoint"=>"http://pip.verisignlabs.com/server", "openid.pape.auth_policies"=>"http://schemas.openid.net/pape/policies/2007/06/none", "openid.claimed_id"=>"http://stutiredboy.pip.verisignlabs.com/", "openid.sig"=>"yNsdpak/yNi+cFp0oxmjtL3DmoY=", "openid.identity"=>"http://stutiredboy.pip.verisignlabs.com/", "openid.ns.pape"=>"http://specs.openid.net/extensions/pape/1.0", "openid.pape.auth_time"=>"2012-03-06T07:16:09Z", "openid.signed"=>"assoc_handle,identity,response_nonce,return_to,claimed_id,op_endpoint,ns.sreg,sreg.nickname,sreg.email,sreg.fullname,ns.pape,pape.auth_policies,pape.auth_time", "openid.ns.sreg"=>"http://openid.net/extensions/sreg/1.1", "openid.return_to"=>"http://114.113.197.25:3000/consumer/complete?did_sreg=y"} Redirected to http://114.113.197.25:3000/consumer Completed 302 Found in 3ms (ActiveRecord: 0.0ms) 


Started GET "/consumer" for 218.107.55.254 at 2012-03-06 18:12:32 +0800 Processing by ConsumerController#index as HTML Rendered consumer/index.html within layouts/application (0.3ms) Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms) 


Started GET "/assets/application.css?body=1" for 218.107.55.254 at 2012-03-06 18:12:32 +0800 Served asset /application.css - 304 Not Modified (0ms) [2012-03-06 18:12:32] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 


Started GET "/assets/jquery_ujs.js?body=1" for 218.107.55.254 at 2012-03-06 18:12:32 +0800 Served asset /jquery_ujs.js - 304 Not Modified (0ms) [2012-03-06 18:12:32] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 


Started GET "/assets/application.js?body=1" for 218.107.55.254 at 2012-03-06 18:12:32 +0800 Served asset /application.js - 304 Not Modified (0ms) [2012-03-06 18:12:32] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 


Started GET "/assets/jquery.js?body=1" for 218.107.55.254 at 2012-03-06 18:12:32 +0800 Served asset /jquery.js - 304 Not Modified (0ms) [2012-03-06 18:12:32] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 
+0

你能粘貼完整的回溯嗎? – shingara 2012-03-06 08:38:44

+0

感謝您的編輯。當然 – stutiredboy 2012-03-06 10:13:20

+0

請自己動手。這不難:( – shingara 2012-03-06 14:30:30

回答

0
*** /usr/local/ruby/lib/ruby/gems/1.9.1/gems/ruby-openid-2.1.8/lib/openid/consumer/idres.rb 2012-03-06 15:13:54.000000000 +0800 
--- /home/tiredboy/login/gem/ruby/1.9.1/gems/ruby-openid-2.1.8/lib/openid/consumer/idres.rb 2012-03-07 13:25:58.000000000 +0800 
*************** 
*** 170,175 **** 
--- 170,178 ---- 
      end 
      @message.get_args(BARE_NS).each_pair do |bare_key, bare_val| 
      rt_val = return_to_parsed_query[bare_key] 
+   if bare_key == "controller" or bare_key == "action" 
+    next 
+   end 
      if not return_to_parsed_query.has_key? bare_key 
       # This may be caused by your web framework throwing extra 
       # entries in to your parameters hash that were not GET or 

我忽略的控制器和動作作爲臨時的解決方案

0

它是由Rails的創建問題,它有時會添加類似「控制器」和「行動的一些參數「在網址中。

而不是修改idres.rb的來源,你可以修改你以這種方式管理返回調用你的Rails控制器:

parameters = params.reject{|k,v|request.path_parameters[k]}.reject{|k,v| k == 'action' || k == 'controller'} 

就像我在紅寶石的OpenID寶石的issue發現在GitHub

這解決了我的問題。