Sha256: 9ebb361cee3f2250ebb10dc163faf0cf239b6d18ef47007422f308b7fdca85cd

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'drillbit/configuration'
require 'drillbit/requests/base'
require 'drillbit/accept_header'
require 'drillbit/tokens/json_web_token'
require 'drillbit/tokens/base64'

module  Drillbit
module  Requests
class   Rails < Base
  def authorization_token_from_params
    if request.params.has_key?(JSON_WEB_TOKEN_PARAM_NAME)
      Tokens::JsonWebToken.__send__(
        "from_#{Drillbit.configuration.token_type.downcase}",
        request.params[JSON_WEB_TOKEN_PARAM_NAME] || '',
        private_key: token_private_key,
      )
    elsif request.params.has_key?(BASE64_TOKEN_PARAM_NAME)
      Tokens::Base64.convert(raw_token: request.params[BASE64_TOKEN_PARAM_NAME] || '')
    else
      Tokens::Null.instance
    end
  end

  private

  def raw_accept_header_from_header
    request.headers['Accept']
  end

  def raw_accept_header_from_params
    request.params['accept']
  end

  def raw_authorization_header
    request.headers['HTTP_AUTHORIZATION'] || ''
  end

  def raw_request_application_name
    request.headers['X-Application-Name']
  end
end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
drillbit-3.0.3 lib/drillbit/requests/rails.rb
drillbit-3.0.2 lib/drillbit/requests/rails.rb
drillbit-3.0.1 lib/drillbit/requests/rails.rb
drillbit-3.0.0 lib/drillbit/requests/rails.rb