Class: CASinoCore::Processor::TwoFactorAuthenticatorRegistrator

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

Overview

The TwoFactorAuthenticatorRegistrator processor can be used as the first step to register a new two-factor authenticator. It is inactive until activated using TwoFactorAuthenticatorActivator.

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::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(cookies = nil, user_agent = nil) ⇒ Object

This method will call #user_not_logged_in or ‘#two_factor_authenticator_registered(two_factor_authenticator)` on the listener.

Parameters:

  • cookies (Hash) (defaults to: nil)

    cookies delivered by the client

  • user_agent (String) (defaults to: nil)

    user-agent delivered by the client



17
18
19
20
21
22
23
24
25
26
# File 'lib/casino_core/processor/two_factor_authenticator_registrator.rb', line 17

def process(cookies = nil, user_agent = nil)
  cookies ||= {}
  tgt = find_valid_ticket_granting_ticket(cookies[:tgt], user_agent)
  if tgt.nil?
    @listener.user_not_logged_in
  else
    two_factor_authenticator = tgt.user.two_factor_authenticators.create! secret: ROTP::Base32.random_base32
    @listener.two_factor_authenticator_registered(two_factor_authenticator)
  end
end