Sha256: 5d2d84676410476fcdb91906e53f3e91ab80279898172b245cc21532f508974d

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

require "easy_auth/version"

module EasyAuth

  def authenticate_token
    reject_request unless authenticated?
  end
  alias_method :easy_authenticate!, :authenticate_token

  def reject_request
    render(:text => 'bad api token', :status => :unauthorized) and return
  end

  def authenticated?
    request_auth_token == authentication_token
  end

  def request_auth_token
    request.env['HTTP_X_API_TOKEN'] || params[:api_token]
  end

  def authentication_token
    ENV.fetch('API_TOKEN') { 'DEV_TOKEN' }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ez_auth-0.0.1 lib/easy_auth.rb