Skip to content

Commit

Permalink
Merge pull request #1076 from SUSE/no-credentials-in-service-url
Browse files Browse the repository at this point in the history
Do not add service credential url paramter if not necessary
  • Loading branch information
felixsch authored Jan 29, 2024
2 parents 024478b + 3b28555 commit 36d721c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/controllers/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ def show

builder = Builder::XmlMarkup.new
service_xml = builder.repoindex(ttl: ZYPPER_SERVICE_TTL) do
# NOTE: We only care to add the ?credentials parameter to the repository URL if
# we are *NOT* dealing with plain RMT but the authentication engine of Public Cloud.
# The engine requires to supply the service name to function properly, since repositories
# are authenticated in this case.
service_name = defined?(StrictAuthentication::Engine) ? service.name : nil

repos.each do |repo|
attributes = {
url: make_repo_url(request.base_url, repo.local_path, service.name),
url: make_repo_url(request.base_url, repo.local_path, service_name),
alias: repo.name,
name: repo.name,
autorefresh: repo.autorefresh,
Expand Down
3 changes: 3 additions & 0 deletions lib/rmt/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module RMT
module Misc
def self.make_repo_url(base_url, local_path, service_name = nil)
uri = URI.join(base_url, File.join(RMT::DEFAULT_MIRROR_URL_PREFIX, local_path))
# NOTE: Make sure to only add the credentials where necessary (Pubcloud? or SMT?)
# In all other cases do not add them, since this will break other repository
# managers such as yum!
uri.query = "credentials=#{service_name}" if service_name
uri.to_s
end
Expand Down
3 changes: 2 additions & 1 deletion package/obs/rmt-server.changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-------------------------------------------------------------------
Wed Oct 04 13:23:00 UTC 2023 - Felix Schnizlein <[email protected]>
Thu Jan 25 17:40:00 UTC 2024 - Felix Schnizlein <[email protected]>

- Version 2.15:
* Moving system hardware information to systems database table to
Expand All @@ -8,6 +8,7 @@ Wed Oct 04 13:23:00 UTC 2023 - Felix Schnizlein <[email protected]>
* rmt-client-setup-res script: fix for CentOS8 clients (bsc#1214709)
* Updated supportconfig script (bsc#1216389)
* Support zstd compression for repository metadata (bsc#1218775)
* Do not add credential handling to normal repository URLs (#1219153)

-------------------------------------------------------------------
Thu Jun 06 15:44:00 UTC 2023 - Luís Caparroz <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/services_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

let(:model_urls) do
service.repositories.reject(&:installer_updates).map do |repo|
RMT::Misc.make_repo_url('http://www.example.com', repo.local_path, service.name)
RMT::Misc.make_repo_url('http://www.example.com', repo.local_path)
end
end

Expand Down

0 comments on commit 36d721c

Please sign in to comment.