module TCellAgent::DeviseInstrumentation::TCellFailureAppRespond

Public Instance Methods

_get_tcell_password() click to toggle source
# File lib/tcell_agent/rails/auth/devise.rb, line 55
def _get_tcell_password
  tcell_password = nil
  TCellAgent::Instrumentation.safe_block('Devise Get TCell Password') do
    user_params = request.POST.fetch('user', {})
    tcell_password = user_params['password']
  end
  tcell_password
end
_get_tcell_username() click to toggle source
# File lib/tcell_agent/rails/auth/devise.rb, line 39
def _get_tcell_username
  tcell_username = nil
  TCellAgent::Instrumentation.safe_block('Devise Get TCell Username') do
    keys = scope_class.authentication_keys.dup
    user_params = request.POST.fetch('user', {})
    keys.each do |key|
      next_usename = user_params.fetch(key, nil)
      if next_usename
        tcell_username ||= ''
        tcell_username += next_usename
      end
    end
  end
  tcell_username
end
respond() click to toggle source
Calls superclass method
# File lib/tcell_agent/rails/auth/devise.rb, line 7
def respond
  TCellAgent::Instrumentation.safe_block('Devise Failure App Respond') do
    if TCellAgent.configuration.should_intercept_requests?
      tcell_data = request.env[TCellAgent::Instrumentation::TCELL_ID]
      if tcell_data
        # in the case of http auth, user_id is set in
        # Devise::Strategies::Authenticatable.valid_for_http_auth?
        user_id = tcell_data.user_id
        user_id ||= _get_tcell_username

        # in the case of http auth, password is set in
        # Devise::Strategies::Authenticatable.valid_for_http_auth?
        password = tcell_data.password
        password ||= _get_tcell_password

        user_valid = warden_message != :not_found_in_database if defined?(warden_message)

        login_policy = TCellAgent.policy(TCellAgent::PolicyTypes::LOGINFRAUD)
        login_policy.report_login_failure(
          user_id,
          password,
          request.env,
          user_valid,
          tcell_data
        )
      end
    end
  end

  super if defined?(super)
end