Merge branch 'louislam:master' into logging

This commit is contained in:
Andreas Brett 2021-11-19 08:56:25 +01:00 committed by GitHub
commit ed96757b24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 142 additions and 69 deletions

60
extra/remove-2fa.js Normal file
View file

@ -0,0 +1,60 @@
console.log("== Uptime Kuma Remove 2FA Tool ==");
console.log("Loading the database");
const Database = require("../server/database");
const { R } = require("redbean-node");
const readline = require("readline");
const TwoFA = require("../server/2fa");
const args = require("args-parser")(process.argv);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const main = async () => {
Database.init(args);
await Database.connect();
try {
// No need to actually reset the password for testing, just make sure no connection problem. It is ok for now.
if (!process.env.TEST_BACKEND) {
const user = await R.findOne("user");
if (! user) {
throw new Error("user not found, have you installed?");
}
console.log("Found user: " + user.username);
let ans = await question("Are you sure want to remove 2FA? [y/N]");
if (ans.toLowerCase() === "y") {
await TwoFA.disable2FA(user.id);
console.log("2FA has been removed successfully.");
}
}
} catch (e) {
console.error("Error: " + e.message);
}
await Database.close();
rl.close();
console.log("Finished.");
};
function question(question) {
return new Promise((resolve) => {
rl.question(question, (answer) => {
resolve(answer);
});
});
}
if (!process.env.TEST_BACKEND) {
main();
}
module.exports = {
main,
};

View file

@ -41,6 +41,7 @@
"update-version": "node extra/update-version.js",
"mark-as-nightly": "node extra/mark-as-nightly.js",
"reset-password": "node extra/reset-password.js",
"remove-2fa": "node extra/remove-2fa.js",
"compile-install-script": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./extra/compile-install-script.ps1",
"test-install-script-centos7": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/centos7.dockerfile .",
"test-install-script-alpine3": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/alpine3.dockerfile .",

14
server/2fa.js Normal file
View file

@ -0,0 +1,14 @@
const { checkLogin } = require("./util-server");
const { R } = require("redbean-node");
class TwoFA {
static async disable2FA(userID) {
return await R.exec("UPDATE `user` SET twofa_status = 0 WHERE id = ? ", [
userID,
]);
}
}
module.exports = TwoFA;

View file

@ -121,6 +121,7 @@ module.exports.io = io;
const { sendNotificationList, sendHeartbeatList, sendImportantHeartbeatList, sendInfo } = require("./client");
const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler");
const databaseSocketHandler = require("./socket-handlers/database-socket-handler");
const TwoFA = require("./2fa");
app.use(express.json());
@ -448,10 +449,7 @@ exports.entryPage = "dashboard";
socket.on("disable2FA", async (callback) => {
try {
checkLogin(socket);
await R.exec("UPDATE `user` SET twofa_status = 0 WHERE id = ? ", [
socket.userID,
]);
await TwoFA.disable2FA(socket.userID);
log_info("auth", `Disabled 2FA token for user ${data.username}. IP=${getClientIp(socket)}`);

View file

@ -175,7 +175,7 @@ export default {
"Entry Page": "Entry Page",
statusPageNothing: "Non c'è nulla qui, aggiungere un gruppo oppure un monitoraggio.",
"No Services": "Nessun Servizio",
"All Systems Operational": "Tutti i sistemi sono operativi",
"All Systems Operational": "Tutti i sistemi sono funzionali",
"Partially Degraded Service": "Servizio parzialmente degradato",
"Degraded Service": "Servizio degradato",
"Add Group": "Aggiungi Gruppo",
@ -304,7 +304,7 @@ export default {
PasswordsDoNotMatch: "Le password non corrispondono.",
records: "records",
"One record": "One record",
steamApiKeyDescription: "Per monitorare un server di gioco Steam si necessita della chiave Steam Web-API. È possibile registrare la propria chiave API qui: ",
steamApiKeyDescription: "Per monitorare un server di gioco Steam si necessita della chiave Web-API di Steam. È possibile registrare la propria chiave API qui: ",
"Current User": "Utente corrente",
recent: "Recenti",
};

View file

@ -17,7 +17,7 @@ export default {
pauseMonitorMsg: "一時停止しますか?",
Settings: "設定",
Dashboard: "ダッシュボード",
"New Update": "New Update",
"New Update": "新しいアップデート",
Language: "言語",
Appearance: "外観",
Theme: "テーマ",
@ -53,7 +53,7 @@ export default {
Ping: "Ping",
"Monitor Type": "監視タイプ",
Keyword: "キーワード",
"Friendly Name": "Friendly Name",
"Friendly Name": "分かりやすい名前",
URL: "URL",
Hostname: "ホスト名",
Port: "ポート",
@ -104,60 +104,60 @@ export default {
"Resolver Server": "問い合わせ先DNSサーバ",
"Resource Record Type": "DNSレコード設定",
"Last Result": "最終結果",
"Create your admin account": "Create your admin account",
"Repeat Password": "Repeat Password",
respTime: "Resp. Time (ms)",
"Create your admin account": "Adminアカウントの作成",
"Repeat Password": "パスワード確認",
respTime: "応答時間 (ms)",
notAvailableShort: "N/A",
Create: "Create",
clearEventsMsg: "Are you sure want to delete all events for this monitor?",
clearHeartbeatsMsg: "Are you sure want to delete all heartbeats for this monitor?",
confirmClearStatisticsMsg: "Are you sure want to delete ALL statistics?",
"Clear Data": "Clear Data",
Events: "Events",
Heartbeats: "Heartbeats",
"Auto Get": "Auto Get",
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
"Default enabled": "Default enabled",
"Also apply to existing monitors": "Also apply to existing monitors",
Export: "Export",
Import: "Import",
backupDescription: "You can backup all monitors and all notifications into a JSON file.",
backupDescription2: "PS: History and event data is not included.",
backupDescription3: "Sensitive data such as notification tokens is included in the export file, please keep it carefully.",
alertNoFile: "Please select a file to import.",
alertWrongFileType: "Please select a JSON file.",
twoFAVerifyLabel: "Please type in your token to verify that 2FA is working",
tokenValidSettingsMsg: "Token is valid! You can now save the 2FA settings.",
confirmEnableTwoFAMsg: "Are you sure you want to enable 2FA?",
confirmDisableTwoFAMsg: "Are you sure you want to disable 2FA?",
"Apply on all existing monitors": "Apply on all existing monitors",
"Verify Token": "Verify Token",
"Setup 2FA": "Setup 2FA",
"Enable 2FA": "Enable 2FA",
"Disable 2FA": "Disable 2FA",
"2FA Settings": "2FA Settings",
"Two Factor Authentication": "Two Factor Authentication",
Create: "作成",
clearEventsMsg: "この監視のすべての記録を削除してもよろしいですか?",
clearHeartbeatsMsg: "この監視のすべての異常記録を削除してもよろしいですか?",
confirmClearStatisticsMsg: "すべての統計を削除してもよろしいですか?",
"Clear Data": "データを削除",
Events: "統計",
Heartbeats: "異常記録",
"Auto Get": "自動取得",
enableDefaultNotificationDescription: "監視を作成するごとに、この通知方法はデフォルトで有効になります。監視ごとに通知を無効にすることもできます。",
"Default enabled": "デフォルトで有効にする",
"Also apply to existing monitors": "既存のモニターにも適用する",
Export: "エクスポート",
Import: "インポート",
backupDescription: "すべての監視と通知方法をJSONファイルにできます。",
backupDescription2: "※ 履歴と統計のデータはバックアップされません。",
backupDescription3: "通知に使用するトークンなどの機密データも含まれています。注意して扱ってください。",
alertNoFile: "インポートするファイルを選択してください。",
alertWrongFileType: "JSONファイルを選択してください。",
twoFAVerifyLabel: "トークンを入力して、2段階認証を有効にします。",
tokenValidSettingsMsg: "トークンの確認が完了しました! 「保存」をしてください。",
confirmEnableTwoFAMsg: "2段階認証を「有効」にします。よろしいですか?",
confirmDisableTwoFAMsg: "2段階認証を「無効」にします。よろしいですか?",
"Apply on all existing monitors": "既存のすべてのモニターに適用する",
"Verify Token": "認証する",
"Setup 2FA": "2段階認証の設定",
"Enable 2FA": "2段階認証を有効にする",
"Disable 2FA": "2段階認証を無効にする",
"2FA Settings": "2段階認証の設定",
"Two Factor Authentication": "2段階認証",
Active: "Active",
Inactive: "Inactive",
Token: "Token",
"Show URI": "Show URI",
"Clear all statistics": "Clear all Statistics",
"Clear all statistics": "すべての記録を削除",
retryCheckEverySecond: "Retry every {0} seconds.",
importHandleDescription: "Choose 'Skip existing' if you want to skip every monitor or notification with the same name. 'Overwrite' will delete every existing monitor and notification.",
confirmImportMsg: "Are you sure to import the backup? Please make sure you've selected the right import option.",
"Heartbeat Retry Interval": "Heartbeat Retry Interval",
"Import Backup": "Import Backup",
"Export Backup": "Export Backup",
"Skip existing": "Skip existing",
Overwrite: "Overwrite",
Options: "Options",
"Keep both": "Keep both",
Tags: "Tags",
"Add New below or Select...": "Add New below or Select...",
"Tag with this name already exist.": "Tag with this name already exist.",
"Tag with this value already exist.": "Tag with this value already exist.",
color: "color",
"value (optional)": "value (optional)",
importHandleDescription: "同じ名前のすべての監視または通知方法を上書きしない場合は、「既存のをスキップ」を選択します。 「上書きする」は、既存のすべてのモニターと通知を削除します。",
confirmImportMsg: "バックアップをインポートしてもよろしいですか?希望するオプションを選択してください。",
"Heartbeat Retry Interval": "異常検知後の再試行間隔",
"Import Backup": "バックアップのインポート",
"Export Backup": "バックアップのエクスポート",
"Skip existing": "既存のをスキップする",
Overwrite: "上書きする",
Options: "オプション",
"Keep both": "どちらも保持する",
Tags: "タグ",
"Add New below or Select...": "新規追加または選択...",
"Tag with this name already exist.": "この名前のタグはすでに存在しています。",
"Tag with this value already exist.": "この値のタグはすでに存在しています。",
color: "",
"value (optional)": " (optional)",
Gray: "Gray",
Red: "Red",
Orange: "Orange",
@ -166,20 +166,20 @@ export default {
Indigo: "Indigo",
Purple: "Purple",
Pink: "Pink",
"Search...": "Search...",
"Avg. Ping": "Avg. Ping",
"Avg. Response": "Avg. Response",
"Entry Page": "Entry Page",
statusPageNothing: "Nothing here, please add a group or a monitor.",
"Search...": "検索...",
"Avg. Ping": "平均Ping時間",
"Avg. Response": "平均応答時間",
"Entry Page": "エントリーページ",
statusPageNothing: "ここには何もありません。グループまたは監視を追加してください。",
"No Services": "No Services",
"All Systems Operational": "All Systems Operational",
"Partially Degraded Service": "Partially Degraded Service",
"Degraded Service": "Degraded Service",
"Add Group": "Add Group",
"Add a monitor": "Add a monitor",
"Edit Status Page": "Edit Status Page",
"Go to Dashboard": "Go to Dashboard",
"Status Page": "Status Page",
"All Systems Operational": "すべてのサービスが稼働中",
"Partially Degraded Service": "部分的にサービスが停止中",
"Degraded Service": "サービスが停止中",
"Add Group": "グループの追加",
"Add a monitor": "監視の追加",
"Edit Status Page": "ステータスページ編集",
"Go to Dashboard": "ダッシュボード",
"Status Page": "ステータスページ",
telegram: "Telegram",
webhook: "Webhook",
smtp: "Email (SMTP)",