Added a form for entering a passphrase for a private ssh key and the corresponding logic for processing a private key
This commit is contained in:
parent
f6ca22ecdd
commit
f3aef67be6
10 changed files with 161 additions and 8 deletions
62
client/ui/qml/Controls/PopupWithInputField.qml
Normal file
62
client/ui/qml/Controls/PopupWithInputField.qml
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
Popup {
|
||||
id: root
|
||||
|
||||
property alias text: textField.text
|
||||
property alias placeholderText: textField.placeholderText
|
||||
property string yesText: "yes"
|
||||
property string noText: "no"
|
||||
property var yesFunc
|
||||
property var noFunc
|
||||
|
||||
signal editingFinished()
|
||||
|
||||
anchors.centerIn: Overlay.overlay
|
||||
modal: true
|
||||
closePolicy: Popup.NoAutoClose
|
||||
|
||||
width: parent.width - 20
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
|
||||
TextField {
|
||||
id: textField
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
Layout.fillWidth: true
|
||||
font.pixelSize: 16
|
||||
echoMode: TextInput.Password
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
BlueButtonType {
|
||||
id: yesButton
|
||||
Layout.preferredWidth: parent.width / 2
|
||||
Layout.fillWidth: true
|
||||
text: yesText
|
||||
onClicked: {
|
||||
root.enabled = false
|
||||
if (yesFunc && typeof yesFunc === "function") {
|
||||
yesFunc()
|
||||
}
|
||||
root.enabled = true
|
||||
}
|
||||
}
|
||||
BlueButtonType {
|
||||
id: noButton
|
||||
Layout.preferredWidth: parent.width / 2
|
||||
Layout.fillWidth: true
|
||||
text: noText
|
||||
onClicked: {
|
||||
if (noFunc && typeof noFunc === "function") {
|
||||
noFunc()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -234,6 +234,9 @@ Window {
|
|||
popupWarning.popupWarningText = message
|
||||
popupWarning.open()
|
||||
}
|
||||
function onShowPassphraseRequestMessage() {
|
||||
popupWithInputField.open()
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
|
|
@ -355,4 +358,21 @@ Window {
|
|||
PopupWarning {
|
||||
id: popupWarning
|
||||
}
|
||||
PopupWithInputField {
|
||||
id: popupWithInputField
|
||||
placeholderText: "Enter private key passphrase"
|
||||
yesFunc: function() {
|
||||
editingFinished()
|
||||
close()
|
||||
UiLogic.passphraseDialogClosed()
|
||||
text = ""
|
||||
}
|
||||
noFunc: function() {
|
||||
close()
|
||||
UiLogic.passphraseDialogClosed()
|
||||
}
|
||||
onEditingFinished: {
|
||||
UiLogic.privateKeyPassphrase = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,16 @@ void UiLogic::initalizeUiLogic()
|
|||
connect(m_notificationHandler, &NotificationHandler::connectRequested, pageLogic<VpnLogic>(), &VpnLogic::onConnect);
|
||||
connect(m_notificationHandler, &NotificationHandler::disconnectRequested, pageLogic<VpnLogic>(), &VpnLogic::onDisconnect);
|
||||
|
||||
auto passphraseCallback = [this]() {
|
||||
emit showPassphraseRequestMessage();
|
||||
QEventLoop loop;
|
||||
QObject::connect(this, &UiLogic::passphraseDialogClosed, &loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
|
||||
return m_privateKeyPassphrase;
|
||||
};
|
||||
m_serverController->setPassphraseCallback(passphraseCallback);
|
||||
|
||||
if (m_settings->serversCount() > 0) {
|
||||
if (m_settings->defaultServerIndex() < 0) m_settings->setDefaultServer(0);
|
||||
emit goToPage(Page::Vpn, true, false);
|
||||
|
|
@ -576,3 +586,4 @@ bool UiLogic::isContainerAlreadyAddedToGui(DockerContainer container)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class UiLogic : public QObject
|
|||
AUTO_PROPERTY(bool, pageEnabled)
|
||||
AUTO_PROPERTY(int, pagesStackDepth)
|
||||
AUTO_PROPERTY(int, currentPageValue)
|
||||
AUTO_PROPERTY(QString, popupWarningText)
|
||||
AUTO_PROPERTY(QString, privateKeyPassphrase);
|
||||
|
||||
READONLY_PROPERTY(QObject *, containersModel)
|
||||
READONLY_PROPERTY(QObject *, protocolsModel)
|
||||
|
|
@ -136,6 +136,9 @@ signals:
|
|||
void toggleLogPanel();
|
||||
void showWarningMessage(QString message);
|
||||
|
||||
void showPassphraseRequestMessage();
|
||||
void passphraseDialogClosed();
|
||||
|
||||
private slots:
|
||||
// containers - INOUT arg
|
||||
void installServer(QPair<amnezia::DockerContainer, QJsonObject> &container);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue