From fa5ac0161ed1292bc900ed6d0593b7d88b792cf8 Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Fri, 4 Nov 2022 15:33:01 +0100 Subject: [PATCH] Fixes #35627 - Registration - Find proxy by certificate (#10315) Use SmartProxyAuth for Smart Proxy detection RFC: https://community.theforeman.org/t/rfc-host-registration-and-load-balancers/30462 Foreman: https://github.com/theforeman/foreman/pull/9464 Smart Proxy: https://projects.theforeman.org/issues/35639 --- .../concerns/api/v2/registration_controller_extensions.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb b/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb index 6a3f7800372..7cdc222de42 100644 --- a/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +++ b/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb @@ -2,6 +2,7 @@ module Katello module Concerns module Api::V2::RegistrationControllerExtensions extend ActiveSupport::Concern + include ::Foreman::Controller::SmartProxyAuth def prepare_host if params['uuid'] @@ -35,7 +36,7 @@ def context_urls def smart_proxy @smart_proxy ||= begin - proxy = params[:url] ? SmartProxy.unscoped.find_by(url: params[:url]) : SmartProxy.pulp_primary + proxy = params[:url] ? find_smart_proxy : SmartProxy.pulp_primary fail Foreman::Exception, _('Smart proxy content source not found!') unless proxy fail Foreman::Exception, _('Pulp 3 is not enabled on Smart proxy!') unless proxy.pulp3_enabled? @@ -43,6 +44,11 @@ def smart_proxy proxy end end + + def find_smart_proxy + auth_smart_proxy + @detected_proxy + end end end end