From 314fa18bdcdab25147d4df3ca3ed754888188e3f Mon Sep 17 00:00:00 2001
From: Adam Stachowicz
Date: Thu, 4 Nov 2021 00:19:04 +0100
Subject: [PATCH 001/174] Fix #871
---
src/components/notifications/Telegram.vue | 32 +++++++++--------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/src/components/notifications/Telegram.vue b/src/components/notifications/Telegram.vue
index 3fe287ee..0fa4dd55 100644
--- a/src/components/notifications/Telegram.vue
+++ b/src/components/notifications/Telegram.vue
@@ -25,13 +25,7 @@
-
- {{ telegramGetUpdatesURL }}
-
-
-
- {{ telegramGetUpdatesURL }}
-
+ {{ telegramGetUpdatesURL() }}
@@ -40,49 +34,47 @@
From 665c263c03936c063a3528047aa33001ce42801e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Bratovi=C4=87?=
Date: Tue, 2 Nov 2021 11:51:45 +0100
Subject: [PATCH 002/174] Add db migrations for new basic auth fields
---
db/patch-monitor-basicauth.sql | 10 ++++++++++
server/database.js | 1 +
2 files changed, 11 insertions(+)
create mode 100644 db/patch-monitor-basicauth.sql
diff --git a/db/patch-monitor-basicauth.sql b/db/patch-monitor-basicauth.sql
new file mode 100644
index 00000000..3a33350d
--- /dev/null
+++ b/db/patch-monitor-basicauth.sql
@@ -0,0 +1,10 @@
+-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
+BEGIN TRANSACTION;
+
+ALTER TABLE monitor
+ ADD basicauth_user TEXT default null;
+
+ALTER TABLE monitor
+ ADD basicauth_pass TEXT default null;
+
+COMMIT;
diff --git a/server/database.js b/server/database.js
index 41d91e85..cc7247f1 100644
--- a/server/database.js
+++ b/server/database.js
@@ -52,6 +52,7 @@ class Database {
"patch-http-monitor-method-body-and-headers.sql": true,
"patch-2fa-invalidate-used-token.sql": true,
"patch-notification_sent_history.sql": true,
+ "patch-monitor-basicauth.sql": true,
}
/**
From 23736549f90eb86afcca919e99e06abfe66c3105 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Bratovi=C4=87?=
Date: Tue, 2 Nov 2021 12:30:44 +0100
Subject: [PATCH 003/174] Implement HTTP basic auth feature
---
server/model/monitor.js | 20 ++++++++++++++++++++
server/server.js | 4 ++++
src/pages/EditMonitor.vue | 10 ++++++++++
3 files changed, 34 insertions(+)
diff --git a/server/model/monitor.js b/server/model/monitor.js
index fc329231..c80e941e 100644
--- a/server/model/monitor.js
+++ b/server/model/monitor.js
@@ -58,6 +58,8 @@ class Monitor extends BeanModel {
method: this.method,
body: this.body,
headers: this.headers,
+ basicauth_user: this.basicauth_user,
+ basicauth_pass: this.basicauth_pass,
hostname: this.hostname,
port: this.port,
maxretries: this.maxretries,
@@ -80,6 +82,15 @@ class Monitor extends BeanModel {
};
}
+ /**
+ * Encode user and password to Base64 encoding
+ * for HTTP "basic" auth, as per RFC-7617
+ * @returns {string}
+ */
+ encodeB64(user, pass) {
+ return btoa(user + ":" + pass);
+ }
+
/**
* Parse to boolean
* @returns {boolean}
@@ -141,6 +152,14 @@ class Monitor extends BeanModel {
// Do not do any queries/high loading things before the "bean.ping"
let startTime = dayjs().valueOf();
+ // HTTP basic auth
+ let basicauthHeader = {};
+ if (this.basicauth_user) {
+ basicauthHeader = {
+ "Authorization": "Basic " + this.encodeB64(this.basicauth_user, this.basicauth_pass)
+ }
+ }
+
const options = {
url: this.url,
method: (this.method || "get").toLowerCase(),
@@ -150,6 +169,7 @@ class Monitor extends BeanModel {
"Accept": "*/*",
"User-Agent": "Uptime-Kuma/" + version,
...(this.headers ? JSON.parse(this.headers) : {}),
+ ...(basicauthHeader)
},
httpsAgent: new https.Agent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
diff --git a/server/server.js b/server/server.js
index d1fd7ff2..76d456c5 100644
--- a/server/server.js
+++ b/server/server.js
@@ -575,6 +575,8 @@ exports.entryPage = "dashboard";
bean.method = monitor.method;
bean.body = monitor.body;
bean.headers = monitor.headers;
+ bean.basicauth_user = monitor.basicauth_user;
+ bean.basicauth_pass = monitor.basicauth_pass;
bean.interval = monitor.interval;
bean.retryInterval = monitor.retryInterval;
bean.hostname = monitor.hostname;
@@ -1139,6 +1141,8 @@ exports.entryPage = "dashboard";
method: monitorListData[i].method || "GET",
body: monitorListData[i].body,
headers: monitorListData[i].headers,
+ basicauth_user: monitorListData[i].basicauth_user,
+ basicauth_pass: monitorListData[i].basicauth_pass,
interval: monitorListData[i].interval,
retryInterval: retryInterval,
hostname: monitorListData[i].hostname,
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index 65c3dad6..18954968 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -265,6 +265,15 @@
+
+
+ {{ $t("HTTP Basic Auth") }}
+
+
+
+
+
+
@@ -487,6 +496,7 @@ export default {
this.monitor.headers = JSON.stringify(JSON.parse(this.monitor.headers), null, 4);
}
+
if (this.isAdd) {
this.$root.add(this.monitor, async (res) => {
From 0dcb7aed21fe9d63ffbdc6c866e0d4cd4485b6c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Bratovi=C4=87?=
Date: Tue, 2 Nov 2021 13:11:33 +0100
Subject: [PATCH 004/174] Delinting
---
server/model/monitor.js | 6 +++---
src/pages/EditMonitor.vue | 3 +--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/server/model/monitor.js b/server/model/monitor.js
index c80e941e..95ef3933 100644
--- a/server/model/monitor.js
+++ b/server/model/monitor.js
@@ -87,9 +87,9 @@ class Monitor extends BeanModel {
* for HTTP "basic" auth, as per RFC-7617
* @returns {string}
*/
- encodeB64(user, pass) {
+ encodeB64(user, pass) {
return btoa(user + ":" + pass);
- }
+ }
/**
* Parse to boolean
@@ -157,7 +157,7 @@ class Monitor extends BeanModel {
if (this.basicauth_user) {
basicauthHeader = {
"Authorization": "Basic " + this.encodeB64(this.basicauth_user, this.basicauth_pass)
- }
+ };
}
const options = {
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index 18954968..f5099aa3 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -266,7 +266,7 @@
-
+
{{ $t("HTTP Basic Auth") }}
@@ -496,7 +496,6 @@ export default {
this.monitor.headers = JSON.stringify(JSON.parse(this.monitor.headers), null, 4);
}
-
if (this.isAdd) {
this.$root.add(this.monitor, async (res) => {
From 179ca232bc85d6a7a0bbedc05d10be5f6e6a003e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Bratovi=C4=87?=
Date: Thu, 4 Nov 2021 10:12:06 +0100
Subject: [PATCH 005/174] Minor refactor - change variable names and add commas
to object definitions
---
...-basicauth.sql => patch-monitor-basic-auth.sql} | 4 ++--
server/database.js | 2 +-
server/model/monitor.js | 14 +++++++-------
server/server.js | 8 ++++----
src/pages/EditMonitor.vue | 4 ++--
5 files changed, 16 insertions(+), 16 deletions(-)
rename db/{patch-monitor-basicauth.sql => patch-monitor-basic-auth.sql} (66%)
diff --git a/db/patch-monitor-basicauth.sql b/db/patch-monitor-basic-auth.sql
similarity index 66%
rename from db/patch-monitor-basicauth.sql
rename to db/patch-monitor-basic-auth.sql
index 3a33350d..de4bdefd 100644
--- a/db/patch-monitor-basicauth.sql
+++ b/db/patch-monitor-basic-auth.sql
@@ -2,9 +2,9 @@
BEGIN TRANSACTION;
ALTER TABLE monitor
- ADD basicauth_user TEXT default null;
+ ADD basic_auth_user TEXT default null;
ALTER TABLE monitor
- ADD basicauth_pass TEXT default null;
+ ADD basic_auth_pass TEXT default null;
COMMIT;
diff --git a/server/database.js b/server/database.js
index cc7247f1..dfc739e0 100644
--- a/server/database.js
+++ b/server/database.js
@@ -52,7 +52,7 @@ class Database {
"patch-http-monitor-method-body-and-headers.sql": true,
"patch-2fa-invalidate-used-token.sql": true,
"patch-notification_sent_history.sql": true,
- "patch-monitor-basicauth.sql": true,
+ "patch-monitor-basic-auth.sql": true,
}
/**
diff --git a/server/model/monitor.js b/server/model/monitor.js
index 95ef3933..f3c823c3 100644
--- a/server/model/monitor.js
+++ b/server/model/monitor.js
@@ -58,8 +58,8 @@ class Monitor extends BeanModel {
method: this.method,
body: this.body,
headers: this.headers,
- basicauth_user: this.basicauth_user,
- basicauth_pass: this.basicauth_pass,
+ basic_auth_user: this.basic_auth_user,
+ basic_auth_pass: this.basic_auth_pass,
hostname: this.hostname,
port: this.port,
maxretries: this.maxretries,
@@ -153,10 +153,10 @@ class Monitor extends BeanModel {
let startTime = dayjs().valueOf();
// HTTP basic auth
- let basicauthHeader = {};
- if (this.basicauth_user) {
- basicauthHeader = {
- "Authorization": "Basic " + this.encodeB64(this.basicauth_user, this.basicauth_pass)
+ let basicAuthHeader = {};
+ if (this.basic_auth_user) {
+ basicAuthHeader = {
+ "Authorization": "Basic " + this.encodeB64(this.basic_auth_user, this.basic_auth_pass),
};
}
@@ -169,7 +169,7 @@ class Monitor extends BeanModel {
"Accept": "*/*",
"User-Agent": "Uptime-Kuma/" + version,
...(this.headers ? JSON.parse(this.headers) : {}),
- ...(basicauthHeader)
+ ...(basicAuthHeader),
},
httpsAgent: new https.Agent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
diff --git a/server/server.js b/server/server.js
index 76d456c5..b1678198 100644
--- a/server/server.js
+++ b/server/server.js
@@ -575,8 +575,8 @@ exports.entryPage = "dashboard";
bean.method = monitor.method;
bean.body = monitor.body;
bean.headers = monitor.headers;
- bean.basicauth_user = monitor.basicauth_user;
- bean.basicauth_pass = monitor.basicauth_pass;
+ bean.basic_auth_user = monitor.basic_auth_user;
+ bean.basic_auth_pass = monitor.basic_auth_pass;
bean.interval = monitor.interval;
bean.retryInterval = monitor.retryInterval;
bean.hostname = monitor.hostname;
@@ -1141,8 +1141,8 @@ exports.entryPage = "dashboard";
method: monitorListData[i].method || "GET",
body: monitorListData[i].body,
headers: monitorListData[i].headers,
- basicauth_user: monitorListData[i].basicauth_user,
- basicauth_pass: monitorListData[i].basicauth_pass,
+ basic_auth_user: monitorListData[i].basic_auth_user,
+ basic_auth_pass: monitorListData[i].basic_auth_pass,
interval: monitorListData[i].interval,
retryInterval: retryInterval,
hostname: monitorListData[i].hostname,
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index f5099aa3..8b3157ea 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -270,9 +270,9 @@
{{ $t("HTTP Basic Auth") }}
-
+
-
+
From 0481a241f3905dc23421a41de6b0ca80836f233c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Bratovi=C4=87?=
Date: Thu, 4 Nov 2021 10:22:42 +0100
Subject: [PATCH 006/174] Add translated placeholders for editing basic auth
---
src/pages/EditMonitor.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index 8b3157ea..108defb7 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -270,9 +270,9 @@
{{ $t("HTTP Basic Auth") }}
-
+
-
+
From baf3612ece8cd143e1766583910b6ab16ecdd0a9 Mon Sep 17 00:00:00 2001
From: Thomas LEVEIL
Date: Fri, 5 Nov 2021 11:27:19 +0100
Subject: [PATCH 007/174] =?UTF-8?q?=F0=9F=9A=B8=20Status=20page=20-=20add?=
=?UTF-8?q?=20group=20action=20adds=20the=20new=20group=20at=20the=20top?=
=?UTF-8?q?=20of=20the=20page?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/StatusPage.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue
index 87634f35..5a2b3551 100644
--- a/src/pages/StatusPage.vue
+++ b/src/pages/StatusPage.vue
@@ -459,7 +459,7 @@ export default {
groupName = "Services";
}
- this.$root.publicGroupList.push({
+ this.$root.publicGroupList.unshift({
name: groupName,
monitorList: [],
});
From ba46fb6b1c126838eae55ed6b5a87de937e00ed7 Mon Sep 17 00:00:00 2001
From: Adam Stachowicz
Date: Wed, 10 Nov 2021 09:11:19 +0100
Subject: [PATCH 008/174] Clickable URL
---
src/components/notifications/Telegram.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/notifications/Telegram.vue b/src/components/notifications/Telegram.vue
index 0fa4dd55..55ff7ec4 100644
--- a/src/components/notifications/Telegram.vue
+++ b/src/components/notifications/Telegram.vue
@@ -25,7 +25,7 @@
- {{ telegramGetUpdatesURL() }}
+ {{ telegramGetUpdatesURL() }}
From 2c85491ee011ca7f7ba655592eb292b2aa5733c7 Mon Sep 17 00:00:00 2001
From: Ivan
Date: Thu, 11 Nov 2021 10:52:22 +0100
Subject: [PATCH 010/174] Replace body and header placeholder functions with
translations
---
src/languages/en.js | 2 ++
src/pages/EditMonitor.vue | 18 ++----------------
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/src/languages/en.js b/src/languages/en.js
index 15c3cd0f..37c1dd69 100644
--- a/src/languages/en.js
+++ b/src/languages/en.js
@@ -307,4 +307,6 @@ export default {
steamApiKeyDescription: "For monitoring a Steam Game Server you need a Steam Web-API key. You can register your API key here: ",
"Current User": "Current User",
recent: "Recent",
+ headersPlaceholder: "Example:\n\{\n \"HeaderName\": \"HeaderValue\"\n}",
+ bodyPlaceholder: "Example:\n\{\n \"key\": \"value\"\n}",
};
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index 65c3dad6..332a9810 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -257,13 +257,13 @@
-
+
-
+
@@ -339,20 +339,6 @@ export default {
return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?msg=OK&ping=";
},
- bodyPlaceholder() {
- return `Example:
-{
- "key": "value"
-}`;
- },
-
- headersPlaceholder() {
- return `Example:
-{
- "HeaderName": "HeaderValue"
-}`;
- }
-
},
watch: {
From 267654c987490d66bace688955badb156516649f Mon Sep 17 00:00:00 2001
From: Ivan
Date: Thu, 11 Nov 2021 10:53:38 +0100
Subject: [PATCH 011/174] Replace hard-coded names for groups in Status page
with translations
---
src/languages/en.js | 3 +++
src/pages/StatusPage.vue | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/languages/en.js b/src/languages/en.js
index 37c1dd69..273ece35 100644
--- a/src/languages/en.js
+++ b/src/languages/en.js
@@ -309,4 +309,7 @@ export default {
recent: "Recent",
headersPlaceholder: "Example:\n\{\n \"HeaderName\": \"HeaderValue\"\n}",
bodyPlaceholder: "Example:\n\{\n \"key\": \"value\"\n}",
+ // Status page
+ "Untitled Group": "Untitled Group",
+ "Services": "Services",
};
diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue
index ce0f94b5..82e46a74 100644
--- a/src/pages/StatusPage.vue
+++ b/src/pages/StatusPage.vue
@@ -468,10 +468,10 @@ export default {
},
addGroup() {
- let groupName = "Untitled Group";
+ let groupName = this.$t("Untitled Group");
if (this.$root.publicGroupList.length === 0) {
- groupName = "Services";
+ groupName = this.$t("Services");
}
this.$root.publicGroupList.push({
From 265cca9ed1db2cbbacf2dc4781407fb1e50a614a Mon Sep 17 00:00:00 2001
From: Ivan
Date: Thu, 11 Nov 2021 10:54:09 +0100
Subject: [PATCH 012/174] Replace "Default" notification badge with translation
---
src/languages/en.js | 1 +
src/pages/EditMonitor.vue | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/languages/en.js b/src/languages/en.js
index 273ece35..6f1a6b5f 100644
--- a/src/languages/en.js
+++ b/src/languages/en.js
@@ -307,6 +307,7 @@ export default {
steamApiKeyDescription: "For monitoring a Steam Game Server you need a Steam Web-API key. You can register your API key here: ",
"Current User": "Current User",
recent: "Recent",
+ Default: "Default",
headersPlaceholder: "Example:\n\{\n \"HeaderName\": \"HeaderValue\"\n}",
bodyPlaceholder: "Example:\n\{\n \"key\": \"value\"\n}",
// Status page
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index 332a9810..907ecfa6 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -215,7 +215,7 @@
{{ $t("Edit") }}
- Default
+ {{ $t("Default") }}