Skip to content

Commit 08f95a9

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 3856b6b + 79d28f0 commit 08f95a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2148
-813
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.12.1
1+
2.12.3

Jenkinsfile

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pipeline {
128128
sh 'docker-compose down --remove-orphans --volumes -t 30 || true'
129129
}
130130
unstable {
131-
dir(path: 'testing/results') {
131+
dir(path: 'test/results') {
132132
archiveArtifacts(allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml')
133133
}
134134
}
@@ -161,7 +161,45 @@ pipeline {
161161
sh 'docker-compose down --remove-orphans --volumes -t 30 || true'
162162
}
163163
unstable {
164-
dir(path: 'testing/results') {
164+
dir(path: 'test/results') {
165+
archiveArtifacts(allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml')
166+
}
167+
}
168+
}
169+
}
170+
stage('Test Postgres') {
171+
environment {
172+
COMPOSE_PROJECT_NAME = "npm_${BRANCH_LOWER}_${BUILD_NUMBER}_postgres"
173+
COMPOSE_FILE = 'docker/docker-compose.ci.yml:docker/docker-compose.ci.postgres.yml'
174+
}
175+
when {
176+
not {
177+
equals expected: 'UNSTABLE', actual: currentBuild.result
178+
}
179+
}
180+
steps {
181+
sh 'rm -rf ./test/results/junit/*'
182+
sh './scripts/ci/fulltest-cypress'
183+
}
184+
post {
185+
always {
186+
// Dumps to analyze later
187+
sh 'mkdir -p debug/postgres'
188+
sh 'docker logs $(docker-compose ps --all -q fullstack) > debug/postgres/docker_fullstack.log 2>&1'
189+
sh 'docker logs $(docker-compose ps --all -q stepca) > debug/postgres/docker_stepca.log 2>&1'
190+
sh 'docker logs $(docker-compose ps --all -q pdns) > debug/postgres/docker_pdns.log 2>&1'
191+
sh 'docker logs $(docker-compose ps --all -q pdns-db) > debug/postgres/docker_pdns-db.log 2>&1'
192+
sh 'docker logs $(docker-compose ps --all -q dnsrouter) > debug/postgres/docker_dnsrouter.log 2>&1'
193+
sh 'docker logs $(docker-compose ps --all -q db-postgres) > debug/postgres/docker_db-postgres.log 2>&1'
194+
sh 'docker logs $(docker-compose ps --all -q authentik) > debug/postgres/docker_authentik.log 2>&1'
195+
sh 'docker logs $(docker-compose ps --all -q authentik-redis) > debug/postgres/docker_authentik-redis.log 2>&1'
196+
sh 'docker logs $(docker-compose ps --all -q authentik-ldap) > debug/postgres/docker_authentik-ldap.log 2>&1'
197+
198+
junit 'test/results/junit/*'
199+
sh 'docker-compose down --remove-orphans --volumes -t 30 || true'
200+
}
201+
unstable {
202+
dir(path: 'test/results') {
165203
archiveArtifacts(allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml')
166204
}
167205
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center">
22
<img src="https://nginxproxymanager.com/github.png">
33
<br><br>
4-
<img src="https://img.shields.io/badge/version-2.12.1-green.svg?style=for-the-badge">
4+
<img src="https://img.shields.io/badge/version-2.12.3-green.svg?style=for-the-badge">
55
<a href="https://hub.docker.com/repository/docker/jc21/nginx-proxy-manager">
66
<img src="https://img.shields.io/docker/stars/jc21/nginx-proxy-manager.svg?style=for-the-badge">
77
</a>

backend/internal/access-list.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const internalAccessList = {
8181

8282
return internalAccessList.build(row)
8383
.then(() => {
84-
if (row.proxy_host_count) {
84+
if (parseInt(row.proxy_host_count, 10)) {
8585
return internalNginx.bulkGenerateConfigs('proxy_host', row.proxy_hosts);
8686
}
8787
})
@@ -223,7 +223,7 @@ const internalAccessList = {
223223
.then((row) => {
224224
return internalAccessList.build(row)
225225
.then(() => {
226-
if (row.proxy_host_count) {
226+
if (parseInt(row.proxy_host_count, 10)) {
227227
return internalNginx.bulkGenerateConfigs('proxy_host', row.proxy_hosts);
228228
}
229229
}).then(internalNginx.reload)
@@ -252,9 +252,13 @@ const internalAccessList = {
252252
let query = accessListModel
253253
.query()
254254
.select('access_list.*', accessListModel.raw('COUNT(proxy_host.id) as proxy_host_count'))
255-
.joinRaw('LEFT JOIN `proxy_host` ON `proxy_host`.`access_list_id` = `access_list`.`id` AND `proxy_host`.`is_deleted` = 0')
255+
.leftJoin('proxy_host', function() {
256+
this.on('proxy_host.access_list_id', '=', 'access_list.id')
257+
.andOn('proxy_host.is_deleted', '=', 0);
258+
})
256259
.where('access_list.is_deleted', 0)
257260
.andWhere('access_list.id', data.id)
261+
.groupBy('access_list.id')
258262
.allowGraph('[owner,items,clients,proxy_hosts.[certificate,access_list.[clients,items]]]')
259263
.first();
260264

@@ -373,7 +377,10 @@ const internalAccessList = {
373377
let query = accessListModel
374378
.query()
375379
.select('access_list.*', accessListModel.raw('COUNT(proxy_host.id) as proxy_host_count'))
376-
.joinRaw('LEFT JOIN `proxy_host` ON `proxy_host`.`access_list_id` = `access_list`.`id` AND `proxy_host`.`is_deleted` = 0')
380+
.leftJoin('proxy_host', function() {
381+
this.on('proxy_host.access_list_id', '=', 'access_list.id')
382+
.andOn('proxy_host.is_deleted', '=', 0);
383+
})
377384
.where('access_list.is_deleted', 0)
378385
.groupBy('access_list.id')
379386
.allowGraph('[owner,items,clients]')
@@ -501,8 +508,13 @@ const internalAccessList = {
501508
if (typeof item.password !== 'undefined' && item.password.length) {
502509
logger.info('Adding: ' + item.username);
503510

504-
utils.execFile('/usr/bin/htpasswd', ['-b', htpasswd_file, item.username, item.password])
505-
.then((/*result*/) => {
511+
utils.execFile('openssl', ['passwd', '-apr1', item.password])
512+
.then((res) => {
513+
try {
514+
fs.appendFileSync(htpasswd_file, item.username + ':' + res + '\n', {encoding: 'utf8'});
515+
} catch (err) {
516+
reject(err);
517+
}
506518
next();
507519
})
508520
.catch((err) => {

backend/internal/audit-log.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const error = require('../lib/error');
2-
const auditLogModel = require('../models/audit-log');
1+
const error = require('../lib/error');
2+
const auditLogModel = require('../models/audit-log');
3+
const {castJsonIfNeed} = require('../lib/helpers');
34

45
const internalAuditLog = {
56

@@ -22,9 +23,9 @@ const internalAuditLog = {
2223
.allowGraph('[user]');
2324

2425
// Query is used for searching
25-
if (typeof search_query === 'string') {
26+
if (typeof search_query === 'string' && search_query.length > 0) {
2627
query.where(function () {
27-
this.where('meta', 'like', '%' + search_query + '%');
28+
this.where(castJsonIfNeed('meta'), 'like', '%' + search_query + '%');
2829
});
2930
}
3031

backend/internal/certificate.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ const internalCertificate = {
313313
.where('is_deleted', 0)
314314
.andWhere('id', data.id)
315315
.allowGraph('[owner]')
316+
.allowGraph('[proxy_hosts]')
317+
.allowGraph('[redirection_hosts]')
318+
.allowGraph('[dead_hosts]')
316319
.first();
317320

318321
if (access_data.permission_visibility !== 'all') {
@@ -464,6 +467,9 @@ const internalCertificate = {
464467
.where('is_deleted', 0)
465468
.groupBy('id')
466469
.allowGraph('[owner]')
470+
.allowGraph('[proxy_hosts]')
471+
.allowGraph('[redirection_hosts]')
472+
.allowGraph('[dead_hosts]')
467473
.orderBy('nice_name', 'ASC');
468474

469475
if (access_data.permission_visibility !== 'all') {

backend/internal/dead-host.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const internalHost = require('./host');
66
const internalNginx = require('./nginx');
77
const internalAuditLog = require('./audit-log');
88
const internalCertificate = require('./certificate');
9+
const {castJsonIfNeed} = require('../lib/helpers');
910

1011
function omissions () {
1112
return ['is_deleted'];
@@ -409,16 +410,16 @@ const internalDeadHost = {
409410
.where('is_deleted', 0)
410411
.groupBy('id')
411412
.allowGraph('[owner,certificate]')
412-
.orderBy('domain_names', 'ASC');
413+
.orderBy(castJsonIfNeed('domain_names'), 'ASC');
413414

414415
if (access_data.permission_visibility !== 'all') {
415416
query.andWhere('owner_user_id', access.token.getUserId(1));
416417
}
417418

418419
// Query is used for searching
419-
if (typeof search_query === 'string') {
420+
if (typeof search_query === 'string' && search_query.length > 0) {
420421
query.where(function () {
421-
this.where('domain_names', 'like', '%' + search_query + '%');
422+
this.where(castJsonIfNeed('domain_names'), 'like', '%' + search_query + '%');
422423
});
423424
}
424425

backend/internal/host.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const _ = require('lodash');
22
const proxyHostModel = require('../models/proxy_host');
33
const redirectionHostModel = require('../models/redirection_host');
44
const deadHostModel = require('../models/dead_host');
5+
const {castJsonIfNeed} = require('../lib/helpers');
56

67
const internalHost = {
78

@@ -17,7 +18,7 @@ const internalHost = {
1718
cleanSslHstsData: function (data, existing_data) {
1819
existing_data = existing_data === undefined ? {} : existing_data;
1920

20-
let combined_data = _.assign({}, existing_data, data);
21+
const combined_data = _.assign({}, existing_data, data);
2122

2223
if (!combined_data.certificate_id) {
2324
combined_data.ssl_forced = false;
@@ -73,7 +74,7 @@ const internalHost = {
7374
* @returns {Promise}
7475
*/
7576
getHostsWithDomains: function (domain_names) {
76-
let promises = [
77+
const promises = [
7778
proxyHostModel
7879
.query()
7980
.where('is_deleted', 0),
@@ -125,19 +126,19 @@ const internalHost = {
125126
* @returns {Promise}
126127
*/
127128
isHostnameTaken: function (hostname, ignore_type, ignore_id) {
128-
let promises = [
129+
const promises = [
129130
proxyHostModel
130131
.query()
131132
.where('is_deleted', 0)
132-
.andWhere('domain_names', 'like', '%' + hostname + '%'),
133+
.andWhere(castJsonIfNeed('domain_names'), 'like', '%' + hostname + '%'),
133134
redirectionHostModel
134135
.query()
135136
.where('is_deleted', 0)
136-
.andWhere('domain_names', 'like', '%' + hostname + '%'),
137+
.andWhere(castJsonIfNeed('domain_names'), 'like', '%' + hostname + '%'),
137138
deadHostModel
138139
.query()
139140
.where('is_deleted', 0)
140-
.andWhere('domain_names', 'like', '%' + hostname + '%')
141+
.andWhere(castJsonIfNeed('domain_names'), 'like', '%' + hostname + '%')
141142
];
142143

143144
return Promise.all(promises)

backend/internal/proxy-host.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const internalHost = require('./host');
66
const internalNginx = require('./nginx');
77
const internalAuditLog = require('./audit-log');
88
const internalCertificate = require('./certificate');
9+
const {castJsonIfNeed} = require('../lib/helpers');
910

1011
function omissions () {
1112
return ['is_deleted', 'owner.is_deleted'];
@@ -449,16 +450,16 @@ const internalProxyHost = {
449450
.where('is_deleted', 0)
450451
.groupBy('id')
451452
.allowGraph('[owner,access_list,certificate]')
452-
.orderBy('domain_names', 'ASC');
453+
.orderBy(castJsonIfNeed('domain_names'), 'ASC');
453454

454455
if (access_data.permission_visibility !== 'all') {
455456
query.andWhere('owner_user_id', access.token.getUserId(1));
456457
}
457458

458459
// Query is used for searching
459-
if (typeof search_query === 'string') {
460+
if (typeof search_query === 'string' && search_query.length > 0) {
460461
query.where(function () {
461-
this.where('domain_names', 'like', '%' + search_query + '%');
462+
this.where(castJsonIfNeed('domain_names'), 'like', `%${search_query}%`);
462463
});
463464
}
464465

backend/internal/redirection-host.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const internalHost = require('./host');
66
const internalNginx = require('./nginx');
77
const internalAuditLog = require('./audit-log');
88
const internalCertificate = require('./certificate');
9+
const {castJsonIfNeed} = require('../lib/helpers');
910

1011
function omissions () {
1112
return ['is_deleted'];
@@ -409,16 +410,16 @@ const internalRedirectionHost = {
409410
.where('is_deleted', 0)
410411
.groupBy('id')
411412
.allowGraph('[owner,certificate]')
412-
.orderBy('domain_names', 'ASC');
413+
.orderBy(castJsonIfNeed('domain_names'), 'ASC');
413414

414415
if (access_data.permission_visibility !== 'all') {
415416
query.andWhere('owner_user_id', access.token.getUserId(1));
416417
}
417418

418419
// Query is used for searching
419-
if (typeof search_query === 'string') {
420+
if (typeof search_query === 'string' && search_query.length > 0) {
420421
query.where(function () {
421-
this.where('domain_names', 'like', '%' + search_query + '%');
422+
this.where(castJsonIfNeed('domain_names'), 'like', `%${search_query}%`);
422423
});
423424
}
424425

0 commit comments

Comments
 (0)