Class: CASinoCore::Processor::TwoFactorAuthenticatorDestroyer

Inherits:
CASinoCore::Processor show all
Includes:
Helper::TicketGrantingTickets, Helper::TwoFactorAuthenticators
Defined in:
lib/casino_core/processor/two_factor_authenticator_destroyer.rb

Overview

The TwoFactorAuthenticatorDestroyer processor can be used to deactivate a previously activated two-factor authenticator.

This feature is not described in the CAS specification so it’s completly optional to implement this on the web application side.

Instance Method Summary collapse

Methods included from Helper::TwoFactorAuthenticators

#validate_one_time_password

Methods included from Helper::TicketGrantingTickets

#acquire_ticket_granting_ticket, #cleanup_expired_ticket_granting_tickets, #find_valid_ticket_granting_ticket, #load_or_initialize_user, #remove_ticket_granting_ticket

Methods included from Helper::Logger

#logger

Methods included from Helper::Browser

#browser_info, #same_browser?

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

The method will call one of the following methods on the listener:

  • #user_not_logged_in: The user is not logged in and should be redirected to /login.

  • #two_factor_authenticator_destroyed: The two-factor authenticator was successfully destroyed.

  • #invalid_two_factor_authenticator: The two-factor authenticator is not valid.

Parameters:

  • params (Hash) (defaults to: nil)

    parameters supplied by user. The processor will look for key :id.

  • cookies (Hash) (defaults to: nil)

    cookies delivered by the client

  • user_agent (String) (defaults to: nil)

    user-agent delivered by the client



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/casino_core/processor/two_factor_authenticator_destroyer.rb', line 22

def process(params = nil, cookies = nil, user_agent = nil)
  cookies ||= {}
  params ||= {}
  tgt = find_valid_ticket_granting_ticket(cookies[:tgt], user_agent)
  if tgt.nil?
    @listener.user_not_logged_in
  else
    authenticator = tgt.user.two_factor_authenticators.where(id: params[:id]).first
    if authenticator
      authenticator.destroy
      @listener.two_factor_authenticator_destroyed
    else
      @listener.invalid_two_factor_authenticator
    end
  end
end