1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
# frozen_string_literal: true
module HTTPX
module Plugins
#
# This plugin adds helper methods to implement HTTP Basic Auth (https://datatracker.ietf.org/doc/html/rfc7617)
#
# https://gitlab.com/os85/httpx/wikis/Auth#basic-auth
#
module BasicAuth
class << self
def load_dependencies(_klass)
require_relative "auth/basic"
end
def configure(klass)
klass.plugin(:auth)
end
end
module InstanceMethods
def basic_auth(user, password)
authorization(Authentication::Basic.new(user, password).authenticate)
end
end
end
register_plugin :basic_auth, BasicAuth
end
end
|