Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Basic authentication instead of on URL user:password #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/backend/lib/docker-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here cause code untidy

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';
}
Expand Down