Sha256: d2200a6c02c15b8f59e599f15059881c59f6222c547bbad6b309ea9191b5e69a

Contents?: true

Size: 755 Bytes

Versions: 4

Compression:

Stored size: 755 Bytes

Contents

require 'uri'

module Proxy
  module ContainerGateway
    class ForemanApi
      def fetch_token(auth_header, params)
        url = URI.join(Proxy::SETTINGS.foreman_url, Proxy::ContainerGateway::Plugin.settings.katello_registry_path, 'token')
        url.query = process_params(params)

        req = Net::HTTP::Get.new(url)
        req.add_field('Authorization', auth_header)
        req.add_field('Accept', 'application/json')
        req.content_type = 'application/json'
        http = Net::HTTP.new(url.hostname, url.port)
        http.use_ssl = true

        http.request(req)
      end

      def process_params(params_in)
        params = params_in.slice('scope', 'account').compact
        URI.encode_www_form(params)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_proxy_container_gateway-1.0.3 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.2 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.1 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.0 lib/smart_proxy_container_gateway/foreman_api.rb