Sha256: 56731aa9be3d2edfbc7839b2edeef98ff2725fa8fe0c01d67943e91bbd230e99

Contents?: true

Size: 1.7 KB

Versions: 18

Compression:

Stored size: 1.7 KB

Contents

module Katello
  class Api::Rhsm::CandlepinDynflowProxyController < Api::V2::ApiController
    include Katello::Authentication::ClientAuthentication
    include ForemanTasks::Triggers
    include AbstractController::Callbacks

    skip_before_action :authorize, :only => [:upload_package_profile]
    before_action :find_host, :only => [:upload_package_profile]
    before_action :authorize_client_or_user, :only => [:upload_package_profile]

    skip_before_action :check_content_type

    #api :PUT, "/consumers/:id/packages", N_("Update installed packages")
    #api :PUT, "/consumers/:id/profile", N_("Update installed packages")
    #param :id, String, :desc => N_("UUID of the consumer"), :required => true
    def upload_package_profile
      User.as_anonymous_admin do
        async_task(::Actions::Katello::Host::UploadPackageProfile, @host, request.raw_post)
      end
      render :json => Resources::Candlepin::Consumer.get(@host.subscription_facet.uuid)
    end

    def find_host(uuid = nil)
      params = request.path_parameters
      uuid ||= params[:id]
      facet = Katello::Host::SubscriptionFacet.where(:uuid => uuid).first
      if facet.nil?
        # check with candlepin if consumer is Gone, raises RestClient::Gone
        User.as_anonymous_admin { Resources::Candlepin::Consumer.get(uuid) }
        fail HttpErrors::NotFound, _("Couldn't find consumer '%s'") % uuid
      end
      @host = facet.host
    end

    def authorize_client_or_user
      client_authorized? || authorize
    end

    def client_authorized?
      authorized = authenticate_client && User.consumer?
      authorized = (User.current.uuid == @host.subscription_facet.uuid) if @host && User.consumer?
      authorized
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
katello-3.9.1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.9.0 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.8.1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.9.0.rc2 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.9.0.rc1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.7.1.1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.7.1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.8.0 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.8.0.rc3 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.8.0.rc2 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.7.0 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.8.0.rc1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.7.0.rc2 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.7.0.rc1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.6.0 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.6.0.1.rc2 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.6.0.rc2 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
katello-3.6.0.rc1 app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb