ruby на рельсах использует исключение openid auth - PullRequest
0 голосов
/ 06 марта 2012

Я использую ruby-openid, чтобы разрешить авторизацию с openid

, когда я использую ruby ​​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

все работает нормально.

, но когдая обновляюсь до:

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

после аутентификации succ от провайдера OpenID и возврата на мою страницу, возникло исключение:

Ошибка проверки: неожиданный параметр (не для return_to): 'controller'= ноль)

Я пытаюсь прочитать 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"=>"stumyreg@gmail.com", "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

Ответы [ 2 ]

0 голосов
/ 14 февраля 2013

Это проблема, созданная Rails, она иногда добавляет некоторые параметры, такие как «controller» и «action» в URL.

Вместо изменения источника idres.rb, вы можете изменить свой контроллер Rails, в которомвы управляете обратным вызовом следующим образом:

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

, как я обнаружил в выпуске в геме ruby-openid на GitHub

Это решило проблему для меня.

0 голосов
/ 07 марта 2012
*** /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

я игнорирую контроллер и действие как временное решение

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...