added processing of private ssh keys
This commit is contained in:
parent
925fd9f268
commit
ebcca0c3b8
10 changed files with 137 additions and 8 deletions
|
|
@ -315,6 +315,10 @@ void AmneziaApplication::initControllers()
|
||||||
|
|
||||||
m_installController.reset(new InstallController(m_serversModel, m_containersModel, m_settings));
|
m_installController.reset(new InstallController(m_serversModel, m_containersModel, m_settings));
|
||||||
m_engine->rootContext()->setContextProperty("InstallController", m_installController.get());
|
m_engine->rootContext()->setContextProperty("InstallController", m_installController.get());
|
||||||
|
connect(m_installController.get(), &InstallController::passphraseRequestStarted, m_pageController.get(),
|
||||||
|
&PageController::showPassphraseRequestDrawer);
|
||||||
|
connect(m_pageController.get(), &PageController::passphraseRequestDrawerClosed, m_installController.get(),
|
||||||
|
&InstallController::setEncryptedPassphrase);
|
||||||
|
|
||||||
m_importController.reset(new ImportController(m_serversModel, m_containersModel, m_settings));
|
m_importController.reset(new ImportController(m_serversModel, m_containersModel, m_settings));
|
||||||
m_engine->rootContext()->setContextProperty("ImportController", m_importController.get());
|
m_engine->rootContext()->setContextProperty("ImportController", m_importController.get());
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "installController.h"
|
#include "installController.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QEventLoop>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
|
@ -396,8 +397,31 @@ void InstallController::mountSftpDrive(const QString &port, const QString &passw
|
||||||
bool InstallController::checkSshConnection()
|
bool InstallController::checkSshConnection()
|
||||||
{
|
{
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
|
|
||||||
ErrorCode errorCode = ErrorCode::NoError;
|
ErrorCode errorCode = ErrorCode::NoError;
|
||||||
|
m_privateKeyPassphrase = "";
|
||||||
|
|
||||||
|
if (m_currentlyInstalledServerCredentials.secretData.contains("BEGIN")
|
||||||
|
&& m_currentlyInstalledServerCredentials.secretData.contains("PRIVATE KEY")) {
|
||||||
|
auto passphraseCallback = [this]() {
|
||||||
|
emit passphraseRequestStarted();
|
||||||
|
QEventLoop loop;
|
||||||
|
QObject::connect(this, &InstallController::passphraseRequestFinished, &loop, &QEventLoop::quit);
|
||||||
|
loop.exec();
|
||||||
|
|
||||||
|
return m_privateKeyPassphrase;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString decryptedPrivateKey;
|
||||||
|
errorCode = serverController.getDecryptedPrivateKey(m_currentlyInstalledServerCredentials, decryptedPrivateKey,
|
||||||
|
passphraseCallback);
|
||||||
|
if (errorCode == ErrorCode::NoError) {
|
||||||
|
m_currentlyInstalledServerCredentials.secretData = decryptedPrivateKey;
|
||||||
|
} else {
|
||||||
|
emit installationErrorOccurred(errorString(errorCode));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString output;
|
QString output;
|
||||||
output = serverController.checkSshConnection(m_currentlyInstalledServerCredentials, &errorCode);
|
output = serverController.checkSshConnection(m_currentlyInstalledServerCredentials, &errorCode);
|
||||||
|
|
||||||
|
|
@ -413,3 +437,9 @@ bool InstallController::checkSshConnection()
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstallController::setEncryptedPassphrase(QString passphrase)
|
||||||
|
{
|
||||||
|
m_privateKeyPassphrase = passphrase;
|
||||||
|
emit passphraseRequestFinished();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ public slots:
|
||||||
|
|
||||||
bool checkSshConnection();
|
bool checkSshConnection();
|
||||||
|
|
||||||
|
void setEncryptedPassphrase(QString passphrase);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void installContainerFinished(QString finishMessage);
|
void installContainerFinished(QString finishMessage);
|
||||||
void installServerFinished(QString finishMessage);
|
void installServerFinished(QString finishMessage);
|
||||||
|
|
@ -55,6 +57,9 @@ signals:
|
||||||
|
|
||||||
void serverAlreadyExists(int serverIndex);
|
void serverAlreadyExists(int serverIndex);
|
||||||
|
|
||||||
|
void passphraseRequestStarted();
|
||||||
|
void passphraseRequestFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installServer(DockerContainer container, QJsonObject &config);
|
void installServer(DockerContainer container, QJsonObject &config);
|
||||||
void installContainer(DockerContainer container, QJsonObject &config);
|
void installContainer(DockerContainer container, QJsonObject &config);
|
||||||
|
|
@ -68,6 +73,8 @@ private:
|
||||||
|
|
||||||
bool m_shouldCreateServer;
|
bool m_shouldCreateServer;
|
||||||
|
|
||||||
|
QString m_privateKeyPassphrase;
|
||||||
|
|
||||||
#ifndef Q_OS_IOS
|
#ifndef Q_OS_IOS
|
||||||
QList<QSharedPointer<QProcess>> m_sftpMountProcesses;
|
QList<QSharedPointer<QProcess>> m_sftpMountProcesses;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,9 @@ signals:
|
||||||
void hideMainWindow();
|
void hideMainWindow();
|
||||||
void raiseMainWindow();
|
void raiseMainWindow();
|
||||||
|
|
||||||
|
void showPassphraseRequestDrawer();
|
||||||
|
void passphraseRequestDrawerClosed(QString passphrase);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ServersModel> m_serversModel;
|
QSharedPointer<ServersModel> m_serversModel;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,11 @@ bool ContainersModel::isAmneziaDnsContainerInstalled(const int serverIndex)
|
||||||
return containers.contains(DockerContainer::Dns);
|
return containers.contains(DockerContainer::Dns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bool ContainersModel::isOnlyServicesInstalled(const int serverIndex)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
QHash<int, QByteArray> ContainersModel::roleNames() const
|
QHash<int, QByteArray> ContainersModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ public slots:
|
||||||
bool isAmneziaDnsContainerInstalled();
|
bool isAmneziaDnsContainerInstalled();
|
||||||
bool isAmneziaDnsContainerInstalled(const int serverIndex);
|
bool isAmneziaDnsContainerInstalled(const int serverIndex);
|
||||||
|
|
||||||
|
// bool isOnlyServicesInstalled(const int serverIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,17 @@ ListView {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case ContainerEnum.WireGuard: {
|
case ContainerEnum.WireGuard: {
|
||||||
WireGuardConfigModel.updateModel(config)
|
ProtocolsModel.updateModel(config)
|
||||||
goToPage(PageEnum.PageProtocolWireGuardSettings)
|
goToPage(PageEnum.PageProtocolRaw)
|
||||||
|
// WireGuardConfigModel.updateModel(config)
|
||||||
|
// goToPage(PageEnum.PageProtocolWireGuardSettings)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case ContainerEnum.Ipsec: {
|
case ContainerEnum.Ipsec: {
|
||||||
Ikev2ConfigModel.updateModel(config)
|
ProtocolsModel.updateModel(config)
|
||||||
goToPage(PageEnum.PageProtocolIKev2Settings)
|
goToPage(PageEnum.PageProtocolRaw)
|
||||||
|
// Ikev2ConfigModel.updateModel(config)
|
||||||
|
// goToPage(PageEnum.PageProtocolIKev2Settings)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case ContainerEnum.Sftp: {
|
case ContainerEnum.Sftp: {
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ PageType {
|
||||||
questionDrawer.yesButtonFunction = function() {
|
questionDrawer.yesButtonFunction = function() {
|
||||||
questionDrawer.visible = false
|
questionDrawer.visible = false
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
if (ServersModel.isDefaultServerCurrentlyProcessed && ConnectionController.isConnected) {
|
if (ServersModel.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected) {
|
||||||
ConnectionController.closeConnection()
|
ConnectionController.closeConnection()
|
||||||
}
|
}
|
||||||
InstallController.removeCurrentlyProcessedServer()
|
InstallController.removeCurrentlyProcessedServer()
|
||||||
|
|
@ -165,7 +165,7 @@ PageType {
|
||||||
questionDrawer.yesButtonFunction = function() {
|
questionDrawer.yesButtonFunction = function() {
|
||||||
questionDrawer.visible = false
|
questionDrawer.visible = false
|
||||||
goToPage(PageEnum.PageDeinstalling)
|
goToPage(PageEnum.PageDeinstalling)
|
||||||
if (ServersModel.isDefaultServerCurrentlyProcessed && ConnectionController.isConnected) {
|
if (ServersModel.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected) {
|
||||||
ConnectionController.closeVpnConnection()
|
ConnectionController.closeVpnConnection()
|
||||||
}
|
}
|
||||||
InstallController.removeAllContainers()
|
InstallController.removeAllContainers()
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ PageType {
|
||||||
PageController.showErrorMessage(errorMessage)
|
PageController.showErrorMessage(errorMessage)
|
||||||
|
|
||||||
var needCloseCurrentPage = false
|
var needCloseCurrentPage = false
|
||||||
var currentPageName = stackView.currentItem.objectName
|
var currentPageName = tabBarStackView.currentItem.objectName
|
||||||
|
|
||||||
if (currentPageName === PageController.getPagePath(PageEnum.PageSetupWizardInstalling)) {
|
if (currentPageName === PageController.getPagePath(PageEnum.PageSetupWizardInstalling)) {
|
||||||
needCloseCurrentPage = true
|
needCloseCurrentPage = true
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,10 @@ Window {
|
||||||
popupNotificationMessage.open()
|
popupNotificationMessage.open()
|
||||||
popupNotificationTimer.start()
|
popupNotificationTimer.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onShowPassphraseRequestDrawer() {
|
||||||
|
privateKeyPassphraseDrawer.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
@ -111,4 +115,74 @@ Window {
|
||||||
id: popupErrorMessage
|
id: popupErrorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
implicitHeight: popupErrorMessage.height
|
||||||
|
|
||||||
|
DrawerType {
|
||||||
|
id: privateKeyPassphraseDrawer
|
||||||
|
|
||||||
|
width: root.width
|
||||||
|
height: root.height * 0.35
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (privateKeyPassphraseDrawer.visible) {
|
||||||
|
passphrase.textFieldText = ""
|
||||||
|
passphrase.textField.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onAboutToHide: {
|
||||||
|
PageController.showBusyIndicator(true)
|
||||||
|
}
|
||||||
|
onAboutToShow: {
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: 16
|
||||||
|
anchors.leftMargin: 16
|
||||||
|
anchors.rightMargin: 16
|
||||||
|
|
||||||
|
TextFieldWithHeaderType {
|
||||||
|
id: passphrase
|
||||||
|
|
||||||
|
property bool hidePassword: true
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
headerText: qsTr("Private key passphrase")
|
||||||
|
textField.echoMode: hidePassword ? TextInput.Password : TextInput.Normal
|
||||||
|
buttonImageSource: hidePassword ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg"
|
||||||
|
|
||||||
|
clickedFunc: function() {
|
||||||
|
hidePassword = !hidePassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicButtonType {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
defaultColor: "transparent"
|
||||||
|
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
|
||||||
|
pressedColor: Qt.rgba(1, 1, 1, 0.12)
|
||||||
|
disabledColor: "#878B91"
|
||||||
|
textColor: "#D7D8DB"
|
||||||
|
borderWidth: 1
|
||||||
|
|
||||||
|
text: qsTr("Save")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
privateKeyPassphraseDrawer.close()
|
||||||
|
PageController.passphraseRequestDrawerClosed(passphrase.textFieldText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue