Sha256: 23754b4f3ea3f5404177297e208dd37466342154776606f81a093451faad626e

Contents?: true

Size: 814 Bytes

Versions: 31

Compression:

Stored size: 814 Bytes

Contents

# frozen_string_literal: true

module HTTPX
  module Plugins
    #
    # This plugin adds helper methods to implement HTTP Basic Auth (https://tools.ietf.org/html/rfc7617)
    #
    # https://gitlab.com/honeyryderchuck/httpx/wikis/Authentication#basic-authentication
    #
    module BasicAuthentication
      class << self
        def load_dependencies(_klass)
          require "base64"
        end

        def configure(klass)
          klass.plugin(:authentication)
        end
      end

      module InstanceMethods
        def basic_authentication(user, password)
          authentication("Basic #{Base64.strict_encode64("#{user}:#{password}")}")
        end
        alias_method :basic_auth, :basic_authentication
      end
    end
    register_plugin :basic_authentication, BasicAuthentication
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
httpx-0.15.4 lib/httpx/plugins/basic_authentication.rb
httpx-0.15.3 lib/httpx/plugins/basic_authentication.rb
httpx-0.15.2 lib/httpx/plugins/basic_authentication.rb
httpx-0.15.1 lib/httpx/plugins/basic_authentication.rb
httpx-0.15.0 lib/httpx/plugins/basic_authentication.rb
httpx-0.14.5 lib/httpx/plugins/basic_authentication.rb
httpx-0.14.4 lib/httpx/plugins/basic_authentication.rb
httpx-0.14.3 lib/httpx/plugins/basic_authentication.rb
httpx-0.14.2 lib/httpx/plugins/basic_authentication.rb
httpx-0.14.1 lib/httpx/plugins/basic_authentication.rb
httpx-0.14.0 lib/httpx/plugins/basic_authentication.rb