Sha256: 43c396c164ca0c1928e0dcc0dfccdab004f307d6d04b21ebf5fb195cd98360a6

Contents?: true

Size: 727 Bytes

Versions: 3

Compression:

Stored size: 727 Bytes

Contents

require 'active_support/concern'

module ActiveResource
  module BearerAuthentication
    module Connection
      extend ActiveSupport::Concern

      included do
        alias authorization_header_without_bearer authorization_header

        def authorization_header(http_method, uri)
          if @password && auth_type == :bearer
            token = @password.is_a?(Proc) ? @password.call : @password
            { 'Authorization' => "Bearer #{token}" }
          else
            authorization_header_without_bearer(http_method, uri)
          end
        end

        def legitimize_auth_type(auth_type)
          [:basic, :digest, :bearer].include?(auth_type) ? auth_type : :basic
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activeresource_bearer_authentication-0.0.3 lib/active_resource/bearer_authentication/connection.rb
activeresource_bearer_authentication-0.0.2 lib/active_resource/bearer_authentication/connection.rb
activeresource_bearer_authentication-0.0.1 lib/active_resource/bearer_authentication/connection.rb