From 6d3afc2849100342870bb869df8cf7c498b7f54a Mon Sep 17 00:00:00 2001 From: Felix Schizlein Date: Thu, 28 Dec 2023 18:10:49 +0100 Subject: [PATCH] Authenticate repository detection calls if needed --- lib/rmt/mirror.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rmt/mirror.rb b/lib/rmt/mirror.rb index a78f94dc7..7e0dce51e 100644 --- a/lib/rmt/mirror.rb +++ b/lib/rmt/mirror.rb @@ -19,7 +19,15 @@ def detect_repository_type } search.each do |key, url| - request = RMT::HttpRequest.new(url, method: :head, followlocation: true) + # Current CDN authenticates via a key append to the request path + # e.g. + # https://update.suse.com/SUSE/product/some-product + # becomes + # https://update.suse.com/SUSE/product/some-product?authenication_tokensiduhashasdyashdaysdasud + uri = URI.join(url) + uri.query = @repository.auth_token if @repository.auth_token + + request = RMT::HttpRequest.new(uri, method: :head, followlocation: true) request.on_success do return key end