From 57ab3755638ce1422a3d24be04c438eb2e2b2144 Mon Sep 17 00:00:00 2001 From: Victor Gil <1392769+Nassiel@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:18:23 +0200 Subject: [PATCH] Basic authentication instead of on URL user:password --- src/backend/lib/docker-registry.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/lib/docker-registry.js b/src/backend/lib/docker-registry.js index dca1438..c0176c2 100644 --- a/src/backend/lib/docker-registry.js +++ b/src/backend/lib/docker-registry.js @@ -13,19 +13,24 @@ const rest = require('restler'); */ module.exports = function (domain, use_ssl, username, password) { - this._baseurl = 'http' + (use_ssl ? 's' : '') + '://' + (username ? username + ':' + password + '@' : '') + domain + '/v2/'; + this._baseurl = 'http' + (use_ssl ? 's' : '') + '://' + domain + '/v2/'; /** * @param {Integer} [version] * @returns {Object} */ this.getUrlOptions = function (version) { - let options = { + let options = { headers: { 'User-Agent': 'Docker Registry UI' } }; + if (username.length > 0 && password.length > 0) { + options.username = username; + options.password = password; + } + if (version === 2) { options.headers.Accept = 'application/vnd.docker.distribution.manifest.v2+json'; }