Class: CASinoCore::Processor::SessionDestroyer

Inherits:
CASinoCore::Processor show all
Includes:
Helper::Logger
Defined in:
lib/casino_core/processor/session_destroyer.rb

Overview

The SessionDestroyer processor is used to destroy a ticket-granting ticket.

This feature is not described in the CAS specification so it’s completly optional to implement this on the web application side. It is especially useful in combination with the SessionOverview processor.

Instance Method Summary collapse

Methods included from Helper::Logger

#logger

Methods inherited from CASinoCore::Processor

#initialize

Constructor Details

This class inherits a constructor from CASinoCore::Processor

Instance Method Details

#process(params = nil, cookies = nil, user_agent = nil) ⇒ Object

This method will call #ticket_not_found or #ticket_deleted on the listener.

Parameters:

  • params (Hash) (defaults to: nil)

    parameters supplied by user (ID of ticket-granting ticket to delete should by in params)

  • cookies (Hash) (defaults to: nil)

    cookies supplied by user

  • user_agent (String) (defaults to: nil)

    user-agent delivered by the client



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/casino_core/processor/session_destroyer.rb', line 18

def process(params = nil, cookies = nil, user_agent = nil)
  params ||= {}
  cookies ||= {}
  ticket = CASinoCore::Model::TicketGrantingTicket.where(id: params[:id]).first
  owner_ticket = CASinoCore::Model::TicketGrantingTicket.where(ticket: cookies[:tgt]).first
  if ticket.nil? || !ticket.same_user?(owner_ticket)
    @listener.ticket_not_found
  else
    logger.info "Destroying ticket-granting ticket '#{ticket.ticket}'"
    ticket.destroy
    @listener.ticket_deleted
  end
end