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.19.8 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.7 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.6 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.5 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.4 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.3 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.2 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.1 lib/httpx/plugins/basic_authentication.rb
httpx-0.19.0 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.7 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.6 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.5 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.4 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.3 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.2 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.1 lib/httpx/plugins/basic_authentication.rb
httpx-0.18.0 lib/httpx/plugins/basic_authentication.rb
httpx-0.17.0 lib/httpx/plugins/basic_authentication.rb
httpx-0.16.1 lib/httpx/plugins/basic_authentication.rb
httpx-0.16.0 lib/httpx/plugins/basic_authentication.rb