Sha256: ecd5b744dd77b3ffbdd22f4ec041a46dcc85a99fc7af323c0b1f7f2da979a238

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

require 'rotp'

# 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.
class CASino::TwoFactorAuthenticatorRegistratorProcessor < CASino::Processor
  include CASino::ProcessorConcern::TicketGrantingTickets

  # This method will call `#user_not_logged_in` or `#two_factor_authenticator_registered(two_factor_authenticator)` on the listener.
  # @param [Hash] cookies cookies delivered by the client
  # @param [String] user_agent user-agent delivered by the client
  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
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
casino-3.0.4 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.7 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-3.0.3 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-3.0.2 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-3.0.1 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-3.0.0 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-3.0.0.pre.2 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-3.0.0.pre.1 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.6 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.5 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.4 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.3 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.2 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.1 app/processors/casino/two_factor_authenticator_registrator_processor.rb
casino-2.0.0 app/processors/casino/two_factor_authenticator_registrator_processor.rb