module ActionController::HttpAuthentication::Basic

def auth_param(request)

def auth_param(request)
  request.authorization.to_s.split(" ", 2).second
end

def auth_scheme(request)

def auth_scheme(request)
  request.authorization.to_s.split(" ", 2).first
end

def authenticate(request, &login_procedure)

def authenticate(request, &login_procedure)
  if has_basic_credentials?(request)
    login_procedure.call(*user_name_and_password(request))
  end
end

def authentication_request(controller, realm, message)

def authentication_request(controller, realm, message)
  message ||= "HTTP Basic: Access denied.\n"
  controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.tr('"', "")}")
  controller.status = 401
  controller.response_body = message
end

def decode_credentials(request)

def decode_credentials(request)
  ::Base64.decode64(auth_param(request) || "")
end

def encode_credentials(user_name, password)

def encode_credentials(user_name, password)
  "Basic #{::Base64.strict_encode64("#{user_name}:#{password}")}"
end

def has_basic_credentials?(request)

def has_basic_credentials?(request)
  request.authorization.present? && (auth_scheme(request).downcase == "basic")
end

def user_name_and_password(request)

def user_name_and_password(request)
  decode_credentials(request).split(":", 2)
end