Created
May 20, 2011 09:37
-
-
Save Electron-libre/982628 to your computer and use it in GitHub Desktop.
single_sign_out.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HectorFetch | |
module InstanceMethods | |
def service_with_fetch | |
res = service_without_fetch | |
current_user.update_from_hector | |
res | |
end | |
def single_sign_out | |
session_ticket = CasTicket.where('_id' => Nokogiri::XML(URI.decode params['logoutRequest']).search("SessionIndex").first.children.first.to_s).first | |
ActionDispatch::Session::MongoidStore::Session.where('_id' => session_ticket.session_id).first.destroy | |
session_ticket.destroy | |
end | |
end | |
def self.included(base) | |
base.class_eval do | |
include InstanceMethods | |
alias_method_chain :service, :fetch | |
end | |
end | |
end | |
module SingleSignOut | |
module AbstractStoreInstanceMethods | |
def call_with_sso(env) | |
res = call_without_sso(env) | |
if env['rack.request.query_hash'].has_key?('ticket') | |
debugger | |
CasTicket.find_or_create_by(:id => env['rack.request.query_hash']['ticket']).update_attribute(:session_id, env['action_dispatch.cookies']['_session_id']) | |
end | |
res | |
end | |
end | |
def self.included(base) | |
base.class_eval do | |
include AbstractStoreInstanceMethods | |
alias_method_chain :call, :sso | |
end | |
end | |
end | |
Taxman::Application.config.to_prepare do | |
Devise::CasSessionsController.class_eval do | |
include HectorFetch | |
end | |
end | |
Taxman::Application.config.after_initialize do | |
ActionDispatch::Session::AbstractStore.class_eval do | |
include SingleSignOut | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment