Sha256: 5bf857c23d419890ff34ddd374349a9d448b4d942f36ad490f8f96ddec8c541c

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

require 'active_support'
require 'active_support/concern'
require 'digest'

module ApiAuthenticator
  extend ActiveSupport::Concern

  # Before filter
  def api_authenticator
    begin
      ApiAuthenticator.authenticated_request?(request)
    rescue BaseError => e
      report_unauthenticated_requests(e)
      render( status: 401, nothing: true ) and return false
    end
  end

  protected

  # TODO: more stuff in here
  def report_unauthenticated_requests(e)
    ApiAuthenticator.logger.warn("failed request #{e.constructed_message}")
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_authenticator-0.3.0 lib/api_authenticator/api_authenticator.rb
api_authenticator-0.2.1 lib/api_authenticator/api_authenticator.rb