Module: Authlogic::Cas::ControllerActions::Service

Included in:
Authlogic::Cas::CasClientController
Defined in:
lib/authlogic_cas/controller_actions/service.rb

Instance Method Summary collapse

Instance Method Details

#serviceObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/authlogic_cas/controller_actions/service.rb', line 5

def service
  cas_scope    = ::Authlogic::Cas.actor_model
  ticket       = ticket_from params
  auth_result  = cas_scope.authenticate_with_cas_ticket(ticket)
  
  (redirect_to(root_path, :notice => "Could not authenticate user") && return) if not auth_result

  if ::Authlogic::Cas.cas_enable_single_sign_out
    unique_cas_id = ticket.respond_to?(:user) ? ticket.user : ticket.response.user
    ::Authlogic::Cas::SingleSignOut::Cache.store_unique_cas_id_for_service_ticket(ticket.ticket, unique_cas_id)
  end

  if Authlogic::Cas.authentication_model.create(auth_result)
    redirect_to(root_path)
  else
    redirect_to(root_path, :notice => "Could not login. Try again please.")
  end
end

#single_signoutObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/authlogic_cas/controller_actions/service.rb', line 24

def single_signout
  if ::Authlogic::Cas.cas_enable_single_sign_out
    service_ticket = read_service_ticket_name

    if service_ticket
      logger.info "Intercepted single-sign-out request for CAS session #{service_ticket}."
      unique_cas_id = ::Authlogic::Cas::SingleSignOut::Cache.find_unique_cas_id_by_service_ticket(service_ticket)
      update_persistence_token_for(unique_cas_id)
    end
  else
    logger.warn "Ignoring CAS single-sign-out request as feature is not currently enabled."
  end

  render :nothing => true
end