Skip to content

Commit

Permalink
Merge pull request #1225 from SUSE/ltss-verification
Browse files Browse the repository at this point in the history
Check LTSS product to verify
  • Loading branch information
jesusbv authored Nov 6, 2024
2 parents 6939106 + 84ec6cf commit 2fadb57
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 2fadb57

Please sign in to comment.