Sha256: 8f7992bd3e52c2e750d9f6ad1dc0c0c0b42f994d5882b9275f6d9481e072549f

Contents?: true

Size: 738 Bytes

Versions: 22

Compression:

Stored size: 738 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
      def self.load_dependencies(klass)
        require "base64"
        klass.plugin(:authentication)
      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

22 entries across 22 versions & 1 rubygems

Version Path
httpx-0.6.3 lib/httpx/plugins/basic_authentication.rb
httpx-0.6.2 lib/httpx/plugins/basic_authentication.rb