cas_devise单点退出不起作用

时间:2013-07-23 15:22:17

标签: ruby-on-rails devise cas

在rails 3.2中构建CAS客户端,我使用扩展名为devise的gem devise_cas

一切正常,登录/退出。

但是当我尝试直接在cas服务器上注销时,使用 single_sign_out 系统一切都会中断,我不知道如何解决我的问题,因为在我看来它来自gem我使用...

当cas服务器试图告诉我有关退出的信息时,以下是我的日志中的内容:

started POST "/UserCasAuth/service" for XX.XX.XX.XX at 2013-07-23 15:08:47 +0000
Processing by Devise::CasSessionsController#single_sign_out as HTML
  Parameters: {"logoutRequest"=>"<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"LR-47-trNqu3YBrJMM7CjeUiySDrsXAe1IrxFse1T\" Version=\"2.0\" IssueInstant=\"2013-07-23T16:58:18Z\"><saml:NameID xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">@NOT_USED@</saml:NameID><samlp:SessionIndex>ST-55-cZPVpgtFwi5ZR5ozc52r-cas</samlp:SessionIndex></samlp:LogoutRequest>"}
Completed 500 Internal Server Error in 2ms

NoMethodError (undefined method `name' for #<ActionDispatch::Session::CookieStore:0x00000005098828>):
  devise_cas_authenticatable (1.3.0) lib/devise_cas_authenticatable/single_sign_out.rb:50:in `destroy_session_by_id'
  devise_cas_authenticatable (1.3.0) app/controllers/devise/cas_sessions_controller.rb:66:in `destroy_cas_session'
  devise_cas_authenticatable (1.3.0) app/controllers/devise/cas_sessions_controller.rb:39:in `single_sign_out'
  actionpack (3.2.12) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.12) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.12) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.12) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.12) lib/active_support/callbacks.rb:425:in `_run__3173126488054142023__process_action__3586998270345349714__callbacks'
  activesupport (3.2.12) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.12) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.12) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.12) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.12) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.12) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.12) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.12) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.12) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.12) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.12) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  actionpack (3.2.12) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.12) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.12) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.12) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.12) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:36:in `call'
  actionpack (3.2.12) lib/action_dispatch/routing/mapper.rb:42:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:601:in `call'
  mongoid (3.1.2) lib/rack/mongoid/middleware/identity_map.rb:34:in `block in call'
  mongoid (3.1.2) lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
  mongoid (3.1.2) lib/rack/mongoid/middleware/identity_map.rb:34:in `call'
  devise_cas_authenticatable (1.3.0) lib/devise_cas_authenticatable/single_sign_out/rack.rb:11:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.1) lib/warden/manager.rb:34:in `catch'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.12) lib/active_support/callbacks.rb:405:in `_run__4068638674135561468__call__4242089574650609487__callbacks'
  activesupport (3.2.12) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.12) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.12) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  rack (1.4.5) lib/rack/sendfile.rb:102:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.12) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.12) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.12) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'
  rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'
  rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.12) lib/rails/engine.rb:479:in `call'
  railties (3.2.12) lib/rails/application.rb:223:in `call'
  railties (3.2.12) lib/rails/railtie/configurable.rb:30:in `method_missing'
  unicorn (4.6.2) lib/unicorn/http_server.rb:552:in `process_client'
  unicorn (4.6.2) lib/unicorn/http_server.rb:632:in `worker_loop'
  unicorn (4.6.2) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
  unicorn (4.6.2) lib/unicorn/http_server.rb:142:in `start'
  unicorn (4.6.2) bin/unicorn_rails:209:in `<top (required)>'
  /usr/local/bin/unicorn_rails:19:in `load'
  /usr/local/bin/unicorn_rails:19:in `<main>'

修改

所以我理解问题来自this file第50行。

我相信没有一个会话经理被认可。 我已经删除了ActiveRecord,因为我正在使用mongoid,如installation doc中所述。那么我应该安装另一个会话管理器吗? 如果没有它,Devise仍然可以工作(直到单点注销),所以我认为它应该不是问题吗?

1 个答案:

答案 0 :(得分:1)

好的解决方案如下:

我可以从gitHub上的this answer了解到,我使用coockieStore存储我的会话,单点注销不支持。

所以我需要

  

使用ActiveRecord会话存储或其他一些数据库持久会话存储

当我从这里知道该怎么做时,我会更新我的答案。

修改

所以解决方案是使用redis作为会话存储。参见redis-store和redis-rails gems。