diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 334bb014..960a5d05 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -15,6 +15,9 @@ OBSWebSocket.Settings.ShowConnectInfo="Show Connect Info" OBSWebSocket.Settings.ShowConnectInfoWarningTitle="Warning: Currently Live" OBSWebSocket.Settings.ShowConnectInfoWarningMessage="It appears that an output (stream, recording, etc.) is currently active." OBSWebSocket.Settings.ShowConnectInfoWarningInfoText="Are you sure that you want to show your connect info?" +OBSWebSocket.Settings.Save.UserPasswordWarningTitle="Warning: Potential Security Issue" +OBSWebSocket.Settings.Save.UserPasswordWarningMessage="obs-websocket stores the server password as plain text. Using a password generated by obs-websocket is highly recommended." +OBSWebSocket.Settings.Save.UserPasswordWarningInfoText="Are you sure you want to use your own password?" OBSWebSocket.SessionTable.Title="Connected WebSocket Sessions" OBSWebSocket.SessionTable.RemoteAddressColumnTitle="Remote Address" diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index a4737394..15abf719 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -23,7 +23,8 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent, Qt::Dialog), ui(new Ui::SettingsDialog), connectInfo(new ConnectInfo), - sessionTableTimer(new QTimer) + sessionTableTimer(new QTimer), + passwordManuallyEdited(false) { ui->setupUi(this); ui->websocketSessionTable->horizontalHeader()->resizeSection(3, 100); // Resize Session Table column widths @@ -45,6 +46,8 @@ SettingsDialog::SettingsDialog(QWidget* parent) : this, &SettingsDialog::GeneratePasswordButtonClicked); connect(ui->showConnectInfoButton, &QPushButton::clicked, this, &SettingsDialog::ShowConnectInfoButtonClicked); + connect(ui->serverPasswordLineEdit, &QLineEdit::textEdited, + this, &SettingsDialog::PasswordEdited); } SettingsDialog::~SettingsDialog() @@ -79,6 +82,8 @@ void SettingsDialog::showEvent(QShowEvent *event) ui->serverPasswordLineEdit->setEnabled(false); } + passwordManuallyEdited = false; + FillSessionTable(); sessionTableTimer->start(1000); @@ -119,6 +124,26 @@ void SettingsDialog::SaveFormData() return; } + // Show a confirmation box to the user if they attempt to provide their own password + if (passwordManuallyEdited && (conf->ServerPassword != ui->serverPasswordLineEdit->text())) { + QMessageBox msgBox; + msgBox.setWindowTitle(obs_module_text("OBSWebSocket.Settings.Save.UserPasswordWarningTitle")); + msgBox.setText(obs_module_text("OBSWebSocket.Settings.Save.UserPasswordWarningMessage")); + msgBox.setInformativeText(obs_module_text("OBSWebSocket.Settings.Save.UserPasswordWarningInfoText")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + int ret = msgBox.exec(); + + switch (ret) { + case QMessageBox::Yes: + break; + case QMessageBox::No: + default: + ui->serverPasswordLineEdit->setText(conf->ServerPassword); + return; + } + } + bool needsRestart = false; if ((conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) || (conf->DebugEnabled != ui->enableDebugLoggingCheckBox->isChecked()) || @@ -222,6 +247,7 @@ void SettingsDialog::GeneratePasswordButtonClicked() QString newPassword = Utils::Crypto::GeneratePassword(); ui->serverPasswordLineEdit->setText(newPassword); ui->serverPasswordLineEdit->selectAll(); + passwordManuallyEdited = false; } void SettingsDialog::ShowConnectInfoButtonClicked() @@ -249,3 +275,8 @@ void SettingsDialog::ShowConnectInfoButtonClicked() connectInfo->raise(); connectInfo->setFocus(); } + +void SettingsDialog::PasswordEdited() +{ + passwordManuallyEdited = true; +} diff --git a/src/forms/SettingsDialog.h b/src/forms/SettingsDialog.h index 66328df9..a8e8e5db 100644 --- a/src/forms/SettingsDialog.h +++ b/src/forms/SettingsDialog.h @@ -24,9 +24,11 @@ private Q_SLOTS: void EnableAuthenticationCheckBoxChanged(); void GeneratePasswordButtonClicked(); void ShowConnectInfoButtonClicked(); + void PasswordEdited(); private: Ui::SettingsDialog *ui; ConnectInfo *connectInfo; QTimer *sessionTableTimer; + bool passwordManuallyEdited; };