From ab3b2bddba0843e7bec6e66bb5d3907bf914bf00 Mon Sep 17 00:00:00 2001 From: Suriya Soutmun Date: Wed, 4 Jan 2023 14:33:05 +0700 Subject: [PATCH 01/53] [empty commit] pull request for http/http keyword mTLS authen From faa78443d6d41659029ce8d3b1c988637c97021d Mon Sep 17 00:00:00 2001 From: Suriya Soutmun Date: Wed, 4 Jan 2023 14:37:03 +0700 Subject: [PATCH 02/53] chore: alter table monitor add column tls_ca, tls_cert, tls_key for certificate data --- db/patch-monitor-tls.sql | 13 +++++++++++++ server/database.js | 1 + 2 files changed, 14 insertions(+) create mode 100644 db/patch-monitor-tls.sql diff --git a/db/patch-monitor-tls.sql b/db/patch-monitor-tls.sql new file mode 100644 index 000000000..ac4edb798 --- /dev/null +++ b/db/patch-monitor-tls.sql @@ -0,0 +1,13 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD tls_ca TEXT default null; + +ALTER TABLE monitor + ADD tls_cert TEXT default null; + +ALTER TABLE monitor + ADD tls_key TEXT default null; + +COMMIT; diff --git a/server/database.js b/server/database.js index 19c09a00f..859f12ff7 100644 --- a/server/database.js +++ b/server/database.js @@ -70,6 +70,7 @@ class Database { "patch-maintenance-table2.sql": true, "patch-add-gamedig-monitor.sql": true, "patch-add-google-analytics-status-page-tag.sql": true, + "patch-monitor-tls.sql": true, }; /** From 43941fa2c60fbd9370699ff4e304188e176a067d Mon Sep 17 00:00:00 2001 From: Suriya Soutmun Date: Wed, 4 Jan 2023 14:37:30 +0700 Subject: [PATCH 03/53] feat: add mtls authen method in http/http keyword --- server/model/monitor.js | 16 ++++++++++++- server/server.js | 3 +++ src/pages/EditMonitor.vue | 47 +++++++++++++++++++++++++++------------ 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 4cbb56e1a..2cb309e08 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -131,6 +131,9 @@ class Monitor extends BeanModel { mqttPassword: this.mqttPassword, authWorkstation: this.authWorkstation, authDomain: this.authDomain, + tlsCa: this.tlsCa, + tlsCert: this.tlsCert, + tlsKey: this.tlsKey, }; } @@ -308,6 +311,18 @@ class Monitor extends BeanModel { options.httpsAgent = new https.Agent(httpsAgentOptions); } + if (this.auth_method === "mtls") { + if (this.tlsCert !== null && this.tlsCert !== "") { + options.httpsAgent.options.cert = Buffer.from(this.tlsCert); + } + if (this.tlsCa !== null && this.tlsCa !== "") { + options.httpsAgent.options.ca = Buffer.from(this.tlsCa); + } + if (this.tlsKey !== null && this.tlsKey !== "") { + options.httpsAgent.options.key = Buffer.from(this.tlsKey); + } + } + log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`); log.debug("monitor", `[${this.name}] Axios Request`); @@ -813,7 +828,6 @@ class Monitor extends BeanModel { domain: this.authDomain, workstation: this.authWorkstation ? this.authWorkstation : undefined }); - } else { res = await axios.request(options); } diff --git a/server/server.js b/server/server.js index 1073f3bef..91b0a9444 100644 --- a/server/server.js +++ b/server/server.js @@ -688,6 +688,9 @@ let needSetup = false; bean.headers = monitor.headers; bean.basic_auth_user = monitor.basic_auth_user; bean.basic_auth_pass = monitor.basic_auth_pass; + bean.tlsCa = monitor.tlsCa; + bean.tlsCert = monitor.tlsCert; + bean.tlsKey = monitor.tlsKey; bean.interval = monitor.interval; bean.retryInterval = monitor.retryInterval; bean.resendInterval = monitor.resendInterval; diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index e9cbd8245..6d7353fee 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -531,28 +531,47 @@ + From 3b74f5f3590d094864770c5b81ed2c3a3f01e443 Mon Sep 17 00:00:00 2001 From: cyril59310 Date: Fri, 17 Feb 2023 19:50:18 +0100 Subject: [PATCH 04/53] empty --- empty | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 empty diff --git a/empty b/empty new file mode 100644 index 000000000..e69de29bb From 8a115670cd78845693214f5800d44b67fddaf82e Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 25 Feb 2023 17:55:40 +0800 Subject: [PATCH 05/53] Fix label and id Co-authored-by: AlexKraus --- src/pages/EditMonitor.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 6d7353fee..085a60db7 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -539,37 +539,37 @@