Sha256: 5d58a3bce07f9772ac1615f2ef90c9469f21359fd8e9f553891024ad435fe33c

Contents?: true

Size: 485 Bytes

Versions: 27

Compression:

Stored size: 485 Bytes

Contents

# frozen_string_literal: true

require "base64"

module HTTPX
  module Plugins
    module Authentication
      class Basic
        def initialize(user, password, **)
          @user = user
          @password = password
        end

        def can_authenticate?(authenticate)
          authenticate && /Basic .*/.match?(authenticate)
        end

        def authenticate(*)
          "Basic #{Base64.strict_encode64("#{@user}:#{@password}")}"
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
httpx-0.21.0 lib/httpx/plugins/authentication/basic.rb
httpx-0.20.5 lib/httpx/plugins/authentication/basic.rb
httpx-0.20.4 lib/httpx/plugins/authentication/basic.rb
httpx-0.20.3 lib/httpx/plugins/authentication/basic.rb
httpx-0.20.2 lib/httpx/plugins/authentication/basic.rb
httpx-0.20.1 lib/httpx/plugins/authentication/basic.rb
httpx-0.20.0 lib/httpx/plugins/authentication/basic.rb