Skip to content

Commit

Permalink
Check LTSS product to verify
Browse files Browse the repository at this point in the history
After a non free extension has been activated successfully
on a PAYG system, RMT calls ZypperAuth verify_instance method
without any other information, the SCC verification of the activation
would fail as there is no product info to check against

Adding the product id present in the request params,
that way RMT can fetch the product class and verify properly

This Fixes bsc#1230154
  • Loading branch information
jesusbv committed Sep 4, 2024
1 parent 085f907 commit 7e12f4a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions engines/zypper_auth/lib/zypper_auth/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def auth_logger
Thread.current[:logger]
end

def verify_instance(request, logger, system)
def verify_instance(request, logger, system, params_product_id = nil)
return false unless request.headers['X-Instance-Data']

instance_data = Base64.decode64(request.headers['X-Instance-Data'].to_s)
Expand All @@ -31,7 +31,7 @@ def verify_instance(request, logger, system)
)

is_valid = verification_provider.instance_valid?
return false if is_valid && system.hybrid? && !handle_scc_subscription(request, system, verification_provider, logger)
return false if is_valid && system.hybrid? && !handle_scc_subscription(request, system, verification_provider, logger, params_product_id)
# update repository and registry cache
InstanceVerification.update_cache(request.remote_ip, system.login, base_product.id)
is_valid
Expand All @@ -49,8 +49,9 @@ def verify_instance(request, logger, system)
false
end

def handle_scc_subscription(request, system, verification_provider, logger)
result = SccProxy.scc_check_subscription_expiration(request.headers, system.login, system.system_token, logger, system.proxy_byos_mode)
def handle_scc_subscription(request, system, verification_provider, logger, params_product_id = nil)
product_class = Product.find_by(id: params_product_id).product_class if params_product_id.present?
result = SccProxy.scc_check_subscription_expiration(request.headers, system.login, system.system_token, logger, system.proxy_byos_mode, product_class)
return true if result[:is_active]

ZypperAuth.zypper_auth_message(request, system, verification_provider, result[:message])
Expand Down Expand Up @@ -128,7 +129,7 @@ def make_repo_url(base_url, repo_local_path, service_name = nil)
# additional validation for zypper service XML controller
before_action :verify_instance
def verify_instance
unless ZypperAuth.verify_instance(request, logger, @system)
unless ZypperAuth.verify_instance(request, logger, @system, params.fetch('id', nil))
render(xml: { error: 'Instance verification failed' }, status: 403)
end
end
Expand Down

0 comments on commit 7e12f4a

Please sign in to comment.