Compare commits

..

37 Commits

Author SHA1 Message Date
Kevin Yue
fab8e7591e Release 1.4.7 2022-06-07 21:46:04 +08:00
Kevin Yue
5a485197b7 Updated VERSION, Bumped 1.4.6 –> 1.4.7 2022-06-07 21:45:49 +08:00
Kevin Yue
7bc02a4208 fix: release resources when properly 2022-06-06 18:05:08 +08:00
Kevin Yue
3067e6e911 fix: add support for parsing tokens from HTML 2022-06-06 15:01:50 +08:00
Samar Dhwoj Acharya
5db77e8404 handle html comment for saml result with okta 2fa (#156) 2022-06-06 13:39:06 +08:00
Kevin Yue
5714063457 chore: use auto to declare variable 2022-06-02 00:19:37 +08:00
Kevin Yue
41f88ed2e0 chore: simplify readme 2022-06-02 00:08:29 +08:00
Kevin Yue
4fada9bd14 Release 1.4.6 2022-06-01 23:55:50 +08:00
Kevin Yue
b57fb993ca Updated VERSION, Bumped 1.4.5 –> 1.4.6 2022-06-01 23:55:40 +08:00
Kevin Yue
f6d06ed978 feat: display address in gateway menu item 2022-06-01 23:53:02 +08:00
Kevin Yue
cc67de3a2b fix: fix bug of parsing the portal respponse 2022-06-01 23:52:12 +08:00
Kevin Yue
e2d28c83b2 Release 1.4.5 2022-05-29 21:15:40 +08:00
Kevin Yue
a489c5881b Updated VERSION, Bumped 1.4.4 –> 1.4.5 2022-05-29 21:15:32 +08:00
Kevin Yue
44fd2f1d3f chore: refine vscode settings 2022-05-29 21:15:01 +08:00
Kevin Yue
9c9b42b87f fix: rollback dbus configuration 2022-05-29 21:00:37 +08:00
Kevin Yue
fb2b148b72 feat: add option to start minimized 2022-05-29 17:33:12 +08:00
Kevin Yue
64bec9660a packaging: fix postinst for debian 2022-05-27 21:32:33 +08:00
Kevin Yue
0619e91bf5 packaging: add postinst for debian 2022-05-26 21:44:31 +08:00
Kevin Yue
048aa4799f test: test debian packaging 2022-05-26 15:33:39 +08:00
Kevin Yue
db0e8b801d test: test debian packaging 2022-05-26 15:12:25 +08:00
Kevin Yue
d03bbc339e test: test debian packaging 2022-05-26 15:06:17 +08:00
Kevin Yue
1312d54d08 test: test debian packaging 2022-05-26 14:41:10 +08:00
Kevin Yue
39f99d9143 test: test debian packaging 2022-05-26 14:23:29 +08:00
Kevin Yue
7a4eb0def3 ci: fix the foder path 2022-05-26 14:13:47 +08:00
Kevin Yue
d9b2094edd chore: apt -> apt-get 2022-05-26 14:11:38 +08:00
Kevin Yue
e6118af9f3 ci: verify debian package 2022-05-26 14:05:59 +08:00
Kevin Yue
108b4be3ec test: test debian packaging 2022-05-26 13:16:20 +08:00
Kevin Yue
65c59e47ec Revert "Revert "fix: improve the dbus security""
This reverts commit 4940830885.
2022-05-26 11:56:14 +08:00
Kevin Yue
177da7f3a2 Revert "Revert "fix: improve the dbus security""
This reverts commit ffa99d3783.
2022-05-26 11:56:06 +08:00
Kevin Yue
d5cd90373b fix: improve the portal config parsing 2022-05-26 11:48:55 +08:00
Kevin Yue
ffa99d3783 Revert "fix: improve the dbus security"
This reverts commit 829298bb84.
2022-05-23 22:20:06 +08:00
Kevin Yue
4940830885 Revert "fix: improve the dbus security"
This reverts commit ad178fe56c.
2022-05-23 22:20:03 +08:00
Kevin Yue
ad178fe56c fix: improve the dbus security 2022-05-23 21:55:21 +08:00
Kevin Yue
829298bb84 fix: improve the dbus security 2022-05-23 21:24:22 +08:00
Kevin Yue
8fe717d844 fix: free resources in slots 2022-05-22 23:17:11 +08:00
Kevin Yue
dffbc64ef5 chore: refine cmake files 2022-05-21 20:55:05 +08:00
Kevin Yue
b99c5a8391 fix: support high DPI screen 2022-05-21 11:43:17 +08:00
27 changed files with 281 additions and 105 deletions

View File

@@ -52,6 +52,10 @@ jobs:
run: | run: |
./scripts/snapshot-archive-all.sh ./scripts/snapshot-archive-all.sh
- name: Verify debian package
run: |
./scripts/verify-debian-package.sh
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: snapshot-source-code name: snapshot-source-code
@@ -174,6 +178,10 @@ jobs:
run: | run: |
./scripts/release-archive-all.sh ./scripts/release-archive-all.sh
- name: Verify debian package
run: |
./scripts/verify-debian-package.sh
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: release-source-code name: release-source-code

1
.gitignore vendored
View File

@@ -8,6 +8,7 @@ build
artifacts artifacts
.cmake .cmake
.idea
# Auto generated DBus files # Auto generated DBus files
*_adaptor.cpp *_adaptor.cpp

View File

@@ -92,7 +92,7 @@ target_link_libraries(gpclient
QtSignals QtSignals
) )
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0 AND CMAKE_BUILD_TYPE STREQUAL Release)
target_compile_options(gpclient PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") target_compile_options(gpclient PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
endif() endif()

View File

@@ -6,7 +6,7 @@ Name=GlobalProtect VPN
Comment=A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports SAML auth mode. Comment=A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports SAML auth mode.
GenericName=GlobalProtect VPN client, supports SAML auth mode GenericName=GlobalProtect VPN client, supports SAML auth mode
Categories=Network;Dialup; Categories=Network;Dialup;
Exec=@CMAKE_INSTALL_PREFIX@/bin/gpclient Exec=env QT_AUTO_SCREEN_SCALE_FACTOR=1 @CMAKE_INSTALL_PREFIX@/bin/gpclient
Icon=com.yuezk.qt.gpclient Icon=com.yuezk.qt.gpclient
Keywords=GlobalProtect;Openconnect;SAML;connection;VPN; Keywords=GlobalProtect;Openconnect;SAML;connection;VPN;
StartupWMClass=gpclient StartupWMClass=gpclient

View File

@@ -162,9 +162,18 @@ void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QSt
SAMLLoginWindow *loginWindow = new SAMLLoginWindow; SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
connect(loginWindow, &SAMLLoginWindow::success, this, &GatewayAuthenticator::onSAMLLoginSuccess); connect(loginWindow, &SAMLLoginWindow::success, [this, loginWindow](const QMap<QString, QString> &samlResult) {
connect(loginWindow, &SAMLLoginWindow::fail, this, &GatewayAuthenticator::onSAMLLoginFail); this->onSAMLLoginSuccess(samlResult);
connect(loginWindow, &SAMLLoginWindow::rejected, this, &GatewayAuthenticator::onLoginWindowRejected); loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::fail, [this, loginWindow](const QString &error) {
this->onSAMLLoginFail(error);
loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::rejected, [this, loginWindow]() {
this->onLoginWindowRejected();
loginWindow->deleteLater();
});
loginWindow->login(samlMethod, samlRequest, preloginUrl); loginWindow->login(samlMethod, samlRequest, preloginUrl);
} }

View File

@@ -35,7 +35,7 @@ GPClient::GPClient(QWidget *parent, IVpn *vpn)
connect(ov, SIGNAL(error(QString)), this, SLOT(onVPNError(QString))); connect(ov, SIGNAL(error(QString)), this, SLOT(onVPNError(QString)));
connect(ov, SIGNAL(logAvailable(QString)), this, SLOT(onVPNLogAvailable(QString))); connect(ov, SIGNAL(logAvailable(QString)), this, SLOT(onVPNLogAvailable(QString)));
// Initiallize the context menu of system tray. // Initialize the context menu of system tray.
initSystemTrayIcon(); initSystemTrayIcon();
initVpnStatus(); initVpnStatus();
} }
@@ -153,7 +153,7 @@ void GPClient::populateGatewayMenu()
if (g.name() == currentGatewayName) { if (g.name() == currentGatewayName) {
iconImage = ":/images/radio_selected.png"; iconImage = ":/images/radio_selected.png";
} }
gatewaySwitchMenu->addAction(QIcon(iconImage), g.name())->setData(i); gatewaySwitchMenu->addAction(QIcon(iconImage), QString("%1 (%2)").arg(g.name(), g.address()))->setData(i);
} }
} }
@@ -279,12 +279,24 @@ void GPClient::portalLogin()
{ {
PortalAuthenticator *portalAuth = new PortalAuthenticator(portal(), settings::get("clientos", "Linux").toString()); PortalAuthenticator *portalAuth = new PortalAuthenticator(portal(), settings::get("clientos", "Linux").toString());
connect(portalAuth, &PortalAuthenticator::success, this, &GPClient::onPortalSuccess); connect(portalAuth, &PortalAuthenticator::success, [this, portalAuth](const PortalConfigResponse response, const QString region) {
this->onPortalSuccess(response, region);
portalAuth->deleteLater();
});
// Prelogin failed on the portal interface, try to treat the portal as a gateway interface // Prelogin failed on the portal interface, try to treat the portal as a gateway interface
connect(portalAuth, &PortalAuthenticator::preloginFailed, this, &GPClient::onPortalPreloginFail); connect(portalAuth, &PortalAuthenticator::preloginFailed, [this, portalAuth](const QString msg) {
connect(portalAuth, &PortalAuthenticator::portalConfigFailed, this, &GPClient::onPortalConfigFail); this->onPortalPreloginFail(msg);
portalAuth->deleteLater();
});
connect(portalAuth, &PortalAuthenticator::portalConfigFailed, [this, portalAuth](const QString msg) {
this->onPortalConfigFail(msg);
portalAuth->deleteLater();
});
// Portal login failed // Portal login failed
connect(portalAuth, &PortalAuthenticator::fail, this, &GPClient::onPortalFail); connect(portalAuth, &PortalAuthenticator::fail, [this, portalAuth](const QString &msg) {
this->onPortalFail(msg);
portalAuth->deleteLater();
});
ui->statusLabel->setText("Authenticating..."); ui->statusLabel->setText("Authenticating...");
updateConnectionStatus(VpnStatus::pending); updateConnectionStatus(VpnStatus::pending);
@@ -295,7 +307,7 @@ void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QS
{ {
PLOGI << "Portal authentication succeeded."; PLOGI << "Portal authentication succeeded.";
// No gateway found in protal configuration // No gateway found in portal configuration
if (portalConfig.allGateways().size() == 0) { if (portalConfig.allGateways().size() == 0) {
PLOGI << "No gateway found in portal configuration, treat the portal address as a gateway."; PLOGI << "No gateway found in portal configuration, treat the portal address as a gateway.";
tryGatewayLogin(); tryGatewayLogin();
@@ -359,8 +371,14 @@ void GPClient::gatewayLogin()
GatewayAuthenticator *gatewayAuth = new GatewayAuthenticator(currentGateway().address(), params); GatewayAuthenticator *gatewayAuth = new GatewayAuthenticator(currentGateway().address(), params);
connect(gatewayAuth, &GatewayAuthenticator::success, this, &GPClient::onGatewaySuccess); connect(gatewayAuth, &GatewayAuthenticator::success, [this, gatewayAuth](const QString &authToken) {
connect(gatewayAuth, &GatewayAuthenticator::fail, this, &GPClient::onGatewayFail); this->onGatewaySuccess(authToken);
gatewayAuth->deleteLater();
});
connect(gatewayAuth, &GatewayAuthenticator::fail, [this, gatewayAuth](const QString &msg) {
this->onGatewayFail(msg);
gatewayAuth->deleteLater();
});
ui->statusLabel->setText("Authenticating..."); ui->statusLabel->setText("Authenticating...");
updateConnectionStatus(VpnStatus::pending); updateConnectionStatus(VpnStatus::pending);

View File

@@ -9,6 +9,7 @@
#include "portalconfigresponse.h" #include "portalconfigresponse.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "vpn.h" #include "vpn.h"
#include "gatewayauthenticator.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class GPClient; } namespace Ui { class GPClient; }
@@ -80,6 +81,8 @@ private:
SettingsDialog *settingsDialog; SettingsDialog *settingsDialog;
QPushButton *settingsButton; QPushButton *settingsButton;
GatewayAuthenticator *gatewayAuthenticator;
bool isQuickConnect { false }; bool isQuickConnect { false };
bool isSwitchingGateway { false }; bool isSwitchingGateway { false };
PortalConfigResponse portalConfig; PortalConfigResponse portalConfig;

View File

@@ -33,7 +33,7 @@ QNetworkReply* gpclient::helper::createRequest(QString url, QByteArray params)
GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName) GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName)
{ {
PLOGI << gateways.size() << " gateway(s) avaiable, filter the gateways with rule: " << ruleName; PLOGI << gateways.size() << " gateway(s) available, filter the gateways with rule: " << ruleName;
GPGateway gateway = gateways.first(); GPGateway gateway = gateways.first();

View File

@@ -1,6 +1,5 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QDir>
#include <QtCore/QStandardPaths> #include <QtCore/QStandardPaths>
#include <plog/Log.h> #include <plog/Log.h>
#include <plog/Init.h> #include <plog/Init.h>
@@ -24,15 +23,15 @@ int main(int argc, char *argv[])
PLOGI << "GlobalProtect started, version: " << VERSION; PLOGI << "GlobalProtect started, version: " << VERSION;
QString port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT)); auto port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
QString hidpiSupport = QString::fromLocal8Bit(qgetenv(QT_AUTO_SCREEN_SCALE_FACTOR)); auto hidpiSupport = QString::fromLocal8Bit(qgetenv(QT_AUTO_SCREEN_SCALE_FACTOR));
if (port.isEmpty()) { if (port.isEmpty()) {
qputenv(ENV_CDP_PORT, "12315"); qputenv(ENV_CDP_PORT, "12315");
} }
if (hidpiSupport.isEmpty()) { if (hidpiSupport.isEmpty()) {
qputenv(QT_AUTO_SCREEN_SCALE_FACTOR, "true"); qputenv(QT_AUTO_SCREEN_SCALE_FACTOR, "1");
} }
SingleApplication app(argc, argv); SingleApplication app(argc, argv);
@@ -46,16 +45,17 @@ int main(int argc, char *argv[])
parser.addOptions({ parser.addOptions({
{"json", "Write the result of the handshake with the GlobalConnect server to stdout as JSON and terminate. Useful for scripting."}, {"json", "Write the result of the handshake with the GlobalConnect server to stdout as JSON and terminate. Useful for scripting."},
{"now", "Do not show the dialog with the connect button; connect immediately instead."}, {"now", "Do not show the dialog with the connect button; connect immediately instead."},
{"start-minimized", "Launch the client minimized."},
}); });
parser.process(app); parser.process(app);
const QStringList positional = parser.positionalArguments(); const auto positional = parser.positionalArguments();
IVpn *vpn = parser.isSet("json") // yes it leaks, but this is cleared on exit anyway auto *vpn = parser.isSet("json") // yes it leaks, but this is cleared on exit anyway
? static_cast<IVpn*>(new VpnJson(nullptr)) // Print to stdout and exit ? static_cast<IVpn*>(new VpnJson(nullptr)) // Print to stdout and exit
: static_cast<IVpn*>(new VpnDbus(nullptr)); // Contact GPService daemon via dbus : static_cast<IVpn*>(new VpnDbus(nullptr)); // Contact GPService daemon via dbus
GPClient w(nullptr, vpn); GPClient w(nullptr, vpn);
w.show(); parser.isSet("start-minimized") ? w.showMinimized() : w.show();
if (positional.size() > 0) { if (positional.size() > 0) {
w.portal(positional.at(0)); w.portal(positional.at(0));

View File

@@ -122,9 +122,18 @@ void PortalAuthenticator::samlAuth()
SAMLLoginWindow *loginWindow = new SAMLLoginWindow; SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
connect(loginWindow, &SAMLLoginWindow::success, this, &PortalAuthenticator::onSAMLLoginSuccess); connect(loginWindow, &SAMLLoginWindow::success, [this, loginWindow](const QMap<QString, QString> samlResult) {
connect(loginWindow, &SAMLLoginWindow::fail, this, &PortalAuthenticator::onSAMLLoginFail); onSAMLLoginSuccess(samlResult);
connect(loginWindow, &SAMLLoginWindow::rejected, this, &PortalAuthenticator::onLoginWindowRejected); loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::fail, [this, loginWindow](const QString msg) {
onSAMLLoginFail(msg);
loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::rejected, [this, loginWindow]() {
onLoginWindowRejected();
loginWindow->deleteLater();
});
loginWindow->login(preloginResponse.samlMethod(), preloginResponse.samlRequest(), preloginUrl); loginWindow->login(preloginResponse.samlMethod(), preloginResponse.samlRequest(), preloginUrl);
} }

View File

@@ -78,10 +78,7 @@ QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader
// Parse the gateways -> external -> list -> entry // Parse the gateways -> external -> list -> entry
if (xmlReader.name() == "entry" && xmlReader.isStartElement()) { if (xmlReader.name() == "entry" && xmlReader.isStartElement()) {
GPGateway g; GPGateway g;
QString address = xmlReader.attributes().value("name").toString(); parseGateway(xmlReader, g);
g.setAddress(address);
g.setPriorityRules(parsePriorityRules(xmlReader));
g.setName(parseGatewayName(xmlReader));
gateways.append(g); gateways.append(g);
} }
} }
@@ -91,45 +88,49 @@ QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader
return gateways; return gateways;
} }
QMap<QString, int> PortalConfigResponse::parsePriorityRules(QXmlStreamReader &xmlReader) void PortalConfigResponse::parseGateway(QXmlStreamReader &reader, GPGateway &gateway) {
{ PLOGI << "Start parsing gateway...";
PLOGI << "Start parsing the priority rules...";
auto finished = false;
while (!finished) {
if (reader.name() == "entry" && reader.isStartElement()) {
auto address = reader.attributes().value("name").toString();
gateway.setAddress(address);
} else if (reader.name() == "description" && reader.isStartElement()) { // gateway name
gateway.setName(reader.readElementText());
} else if (reader.name() == "priority-rule" && reader.isStartElement()) { // priority rules
parsePriorityRule(reader, gateway);
}
auto result = reader.readNext();
finished = result == QXmlStreamReader::Invalid || (reader.name() == "entry" && reader.isEndElement());
}
}
void PortalConfigResponse::parsePriorityRule(QXmlStreamReader &reader, GPGateway &gateway) {
PLOGI << "Start parsing priority rule...";
QMap<QString, int> priorityRules; QMap<QString, int> priorityRules;
auto finished = false;
while ((xmlReader.name() != "priority-rule" || !xmlReader.isEndElement()) && !xmlReader.hasError()) { while (!finished) {
xmlReader.readNext(); // Parse the priority-rule -> entry
if (reader.name() == "entry" && reader.isStartElement()) {
if (xmlReader.name() == "entry" && xmlReader.isStartElement()) { auto ruleName = reader.attributes().value("name").toString();
QString ruleName = xmlReader.attributes().value("name").toString(); // move to the priority value
// Read the priority tag while (reader.readNextStartElement()) {
while (xmlReader.name() != "priority"){ if (reader.name() == "priority") {
xmlReader.readNext(); auto priority = reader.readElementText().toInt();
} priorityRules.insert(ruleName, priority);
int ruleValue = xmlReader.readElementText().toUInt(); break;
priorityRules.insert(ruleName, ruleValue);
} }
} }
}
PLOGI << "Finished parsing the priority rules."; auto result = reader.readNext();
finished = result == QXmlStreamReader::Invalid || (reader.name() == "priority-rule" && reader.isEndElement());
return priorityRules;
} }
QString PortalConfigResponse::parseGatewayName(QXmlStreamReader &xmlReader) gateway.setPriorityRules(priorityRules);
{
PLOGI << "Start parsing the gateway name...";
while (xmlReader.name() != "description" || !xmlReader.isEndElement()) {
xmlReader.readNext();
if (xmlReader.name() == "description" && xmlReader.tokenType() == xmlReader.StartElement) {
PLOGI << "Finished parsing the gateway name";
return xmlReader.readElementText();
}
}
PLOGE << "Error: <description> tag not found";
return "";
} }
QString PortalConfigResponse::userAuthCookie() const QString PortalConfigResponse::userAuthCookie() const
@@ -137,11 +138,6 @@ QString PortalConfigResponse::userAuthCookie() const
return m_userAuthCookie; return m_userAuthCookie;
} }
QString PortalConfigResponse::prelogonUserAuthCookie() const
{
return m_prelogonAuthCookie;
}
QList<GPGateway> PortalConfigResponse::allGateways() const QList<GPGateway> PortalConfigResponse::allGateways() const
{ {
return m_gateways; return m_gateways;
@@ -176,3 +172,4 @@ void PortalConfigResponse::setPrelogonUserAuthCookie(const QString cookie)
{ {
m_prelogonAuthCookie = cookie; m_prelogonAuthCookie = cookie;
} }

View File

@@ -19,7 +19,6 @@ public:
const QString &username() const; const QString &username() const;
QString password() const; QString password() const;
QString userAuthCookie() const; QString userAuthCookie() const;
QString prelogonUserAuthCookie() const;
QList<GPGateway> allGateways() const; QList<GPGateway> allGateways() const;
void setAllGateways(QList<GPGateway> gateways); void setAllGateways(QList<GPGateway> gateways);
@@ -44,8 +43,9 @@ private:
void setPrelogonUserAuthCookie(const QString cookie); void setPrelogonUserAuthCookie(const QString cookie);
static QList<GPGateway> parseGateways(QXmlStreamReader &xmlReader); static QList<GPGateway> parseGateways(QXmlStreamReader &xmlReader);
static QMap<QString, int> parsePriorityRules(QXmlStreamReader &xmlReader); static void parseGateway(QXmlStreamReader &reader, GPGateway &gateway);
static QString parseGatewayName(QXmlStreamReader &xmlReader); static void parsePriorityRule(QXmlStreamReader &reader, GPGateway &gateway);
}; };
#endif // PORTALCONFIGRESPONSE_H #endif // PORTALCONFIGRESPONSE_H

View File

@@ -15,6 +15,7 @@ SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
QVBoxLayout *verticalLayout = new QVBoxLayout(this); QVBoxLayout *verticalLayout = new QVBoxLayout(this);
webView->setUrl(QUrl("about:blank")); webView->setUrl(QUrl("about:blank"));
webView->setAttribute(Qt::WA_DeleteOnClose);
// webView->page()->profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); // webView->page()->profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
verticalLayout->addWidget(webView); verticalLayout->addWidget(webView);
@@ -57,12 +58,17 @@ void SAMLLoginWindow::onResponseReceived(QJsonObject params)
QJsonObject response = params.value("response").toObject(); QJsonObject response = params.value("response").toObject();
QJsonObject headers = response.value("headers").toObject(); QJsonObject headers = response.value("headers").toObject();
LOGI << "Trying to receive from " << response.value("url").toString();
const QString username = headers.value("saml-username").toString(); const QString username = headers.value("saml-username").toString();
const QString preloginCookie = headers.value("prelogin-cookie").toString(); const QString preloginCookie = headers.value("prelogin-cookie").toString();
const QString userAuthCookie = headers.value("portal-userauthcookie").toString(); const QString userAuthCookie = headers.value("portal-userauthcookie").toString();
LOGI << "Response received from " << response.value("url").toString(); this->checkSamlResult(username, preloginCookie, userAuthCookie);
}
void SAMLLoginWindow::checkSamlResult(QString username, QString preloginCookie, QString userAuthCookie)
{
if (!username.isEmpty()) { if (!username.isEmpty()) {
LOGI << "Got username from SAML response headers " << username; LOGI << "Got username from SAML response headers " << username;
samlResult.insert("username", username); samlResult.insert("username", username);
@@ -89,11 +95,38 @@ void SAMLLoginWindow::onResponseReceived(QJsonObject params)
emit success(samlResult); emit success(samlResult);
accept(); accept();
} else { } else {
this->show(); show();
} }
} }
void SAMLLoginWindow::onLoadFinished() void SAMLLoginWindow::onLoadFinished()
{ {
LOGI << "Load finished " << this->webView->page()->url().toString(); LOGI << "Load finished " << webView->page()->url().toString();
webView->page()->toHtml([this] (const QString &html) { this->handleHtml(html); });
}
void SAMLLoginWindow::handleHtml(const QString &html)
{
// try to check the html body and extract from there
const QRegularExpression regex("<saml-auth-status>(.*)</saml-auth-status>");
const QRegularExpressionMatch match = regex.match(html);
const QString samlAuthStatusOnBody = match.captured(1);
if (samlAuthStatusOnBody == "1") {
const QRegularExpression preloginCookieRegex("<prelogin-cookie>(.*)</prelogin-cookie>");
const QRegularExpressionMatch preloginCookieMatch = preloginCookieRegex.match(html);
const QString preloginCookie = preloginCookieMatch.captured(1);
const QRegularExpression usernameRegex("<saml-username>(.*)</saml-username>");
const QRegularExpressionMatch usernameMatch = usernameRegex.match(html);
const QString username = usernameMatch.captured(1);
const QRegularExpression userAuthCookieRegex("<portal-userauthcookie>(.*)</portal-userauthcookie>");
const QRegularExpressionMatch userAuthCookieMatch = userAuthCookieRegex.match(html);
const QString userAuthCookie = userAuthCookieMatch.captured(1);
checkSamlResult(username, preloginCookie, userAuthCookie);
} else {
show();
}
} }

View File

@@ -24,12 +24,14 @@ signals:
private slots: private slots:
void onResponseReceived(QJsonObject params); void onResponseReceived(QJsonObject params);
void onLoadFinished(); void onLoadFinished();
void checkSamlResult(QString username, QString preloginCookie, QString userAuthCookie);
private: private:
EnhancedWebView *webView; EnhancedWebView *webView;
QMap<QString, QString> samlResult; QMap<QString, QString> samlResult;
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void handleHtml(const QString &html);
}; };
#endif // SAMLLOGINWINDOW_H #endif // SAMLLOGINWINDOW_H

View File

@@ -4,6 +4,12 @@ project(GPService)
set(gpservice_GENERATED_SOURCES) set(gpservice_GENERATED_SOURCES)
execute_process(COMMAND logname OUTPUT_VARIABLE CMAKE_LOGNAME)
string(STRIP "${CMAKE_LOGNAME}" CMAKE_LOGNAME)
message(STATUS "CMAKE_LOGNAME: ${CMAKE_LOGNAME}")
configure_file(dbus/com.yuezk.qt.GPService.conf.in dbus/com.yuezk.qt.GPService.conf)
configure_file(dbus/com.yuezk.qt.GPService.service.in dbus/com.yuezk.qt.GPService.service) configure_file(dbus/com.yuezk.qt.GPService.service.in dbus/com.yuezk.qt.GPService.service)
configure_file(systemd/gpservice.service.in systemd/gpservice.service) configure_file(systemd/gpservice.service.in systemd/gpservice.service)
@@ -65,7 +71,7 @@ target_link_libraries(gpservice
target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication) target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication)
install(TARGETS gpservice DESTINATION bin) install(TARGETS gpservice DESTINATION bin)
install(FILES "dbus/com.yuezk.qt.GPService.conf" DESTINATION share/dbus-1/system.d ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dbus/com.yuezk.qt.GPService.conf" DESTINATION share/dbus-1/system.d )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dbus/com.yuezk.qt.GPService.service" DESTINATION share/dbus-1/system-services) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dbus/com.yuezk.qt.GPService.service" DESTINATION share/dbus-1/system-services)
install(FILES "gp.conf" DESTINATION /etc/gpservice) install(FILES "gp.conf" DESTINATION /etc/gpservice)

View File

@@ -136,7 +136,7 @@ void GPService::connect(QString server, QString username, QString passwd)
<< "--cookie-on-stdin" << "--cookie-on-stdin"
<< server; << server;
log("Start process with arugments: " + args.join(" ")); log("Start process with arugments: " + args.join(", "));
openconnect->start(bin, args); openconnect->start(bin, args);
openconnect->write((passwd + "\n").toUtf8()); openconnect->write((passwd + "\n").toUtf8());

View File

@@ -42,7 +42,7 @@ Add the repository in the above table and install it with your favorite package
```sh ```sh
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
sudo apt-get update sudo apt-get update
sudo apt install globalprotect-openconnect sudo apt-get install globalprotect-openconnect
``` ```
> For Linux Mint, you might need to import the GPG key with: `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7937C393082992E5D6E4A60453FC26B43838D761` if you encountered an error `gpg: keyserver receive failed: General error`. > For Linux Mint, you might need to import the GPG key with: `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7937C393082992E5D6E4A60453FC26B43838D761` if you encountered an error `gpg: keyserver receive failed: General error`.
@@ -105,7 +105,7 @@ cd GlobalProtect-openconnect
> >
> ```sh > ```sh
> sudo add-apt-repository ppa:dwmw2/openconnect > sudo add-apt-repository ppa:dwmw2/openconnect
> sudo apt update > sudo apt-get update
> ``` > ```
Build and install with: Build and install with:
@@ -176,15 +176,6 @@ Install the [AppIndicator and KStatusNotifierItem Support](https://extensions.gn
<p> <p>
## Future plan
- [x] Improve the release process
- [ ] Process bugs and feature requests
- [ ] Support for bypassing the `gpclient` parameters
- [ ] Support the CLI mode
## Troubleshooting ## Troubleshooting
Run `gpclient` in the Terminal and collect the logs. Run `gpclient` in the Terminal and collect the logs.

View File

@@ -1 +1 @@
1.4.4 1.4.7

41
debian/changelog vendored
View File

@@ -1,3 +1,44 @@
globalprotect-openconnect (1.4.7-1) unstable; urgency=medium
* Updated VERSION, Bumped 1.4.6 > 1.4.7
* fix: release resources when properly
* fix: add support for parsing tokens from HTML
* handle html comment for saml result with okta 2fa (#156)
* chore: use auto to declare variable
* chore: simplify readme
-- Kevin Yue <k3vinyue@gmail.com> Tue, 07 Jun 2022 21:46:04 +0800
globalprotect-openconnect (1.4.6-1) unstable; urgency=medium
* Updated VERSION, Bumped 1.4.5 > 1.4.6
* feat: display address in gateway menu item
* fix: fix bug of parsing the portal respponse
-- Kevin Yue <k3vinyue@gmail.com> Wed, 01 Jun 2022 23:55:50 +0800
globalprotect-openconnect (1.4.5-1) unstable; urgency=medium
* Updated VERSION, Bumped 1.4.4 > 1.4.5
* chore: refine vscode settings
* fix: rollback dbus configuration
* feat: add option to start minimized
* packaging: fix postinst for debian
* packaging: add postinst for debian
* test: test debian packaging
* ci: fix the foder path
* chore: apt -> apt-get
* ci: verify debian package
* Revert "Revert "fix: improve the dbus security""
* fix: improve the portal config parsing
* Revert "fix: improve the dbus security"
* fix: improve the dbus security
* fix: free resources in slots
* chore: refine cmake files
* fix: support high DPI screen
-- Kevin Yue <k3vinyue@gmail.com> Sun, 29 May 2022 21:15:40 +0800
globalprotect-openconnect (1.4.4-1) unstable; urgency=medium globalprotect-openconnect (1.4.4-1) unstable; urgency=medium
* Updated VERSION, Bumped 1.4.3 > 1.4.4 * Updated VERSION, Bumped 1.4.3 > 1.4.4

View File

@@ -1,7 +1,7 @@
# Maintainer: Keinv Yue <yuezk001@gmail.com> # Maintainer: Keinv Yue <yuezk001@gmail.com>
_pkgver="1.4.4" _pkgver="1.4.7"
_commit="4327235093159c6569af33021d4c763ebea3787a" _commit="5a485197b7c7b17f064d89bfe98ec1733d60e221"
pkgname=globalprotect-openconnect-git pkgname=globalprotect-openconnect-git
pkgver=${_pkgver} pkgver=${_pkgver}
pkgrel=1 pkgrel=1

View File

@@ -1,3 +1,44 @@
-------------------------------------------------------------------
Tue Jun 7 13:46:04 UTC 2022 - k3vinyue@gmail.com - 1.4.7
- Update to 1.4.7
* Updated VERSION, Bumped 1.4.6 > 1.4.7
* fix: release resources when properly
* fix: add support for parsing tokens from HTML
* handle html comment for saml result with okta 2fa (#156)
* chore: use auto to declare variable
* chore: simplify readme
-------------------------------------------------------------------
Wed Jun 1 15:55:50 UTC 2022 - k3vinyue@gmail.com - 1.4.6
- Update to 1.4.6
* Updated VERSION, Bumped 1.4.5 > 1.4.6
* feat: display address in gateway menu item
* fix: fix bug of parsing the portal respponse
-------------------------------------------------------------------
Sun May 29 13:15:40 UTC 2022 - k3vinyue@gmail.com - 1.4.5
- Update to 1.4.5
* Updated VERSION, Bumped 1.4.4 > 1.4.5
* chore: refine vscode settings
* fix: rollback dbus configuration
* feat: add option to start minimized
* packaging: fix postinst for debian
* packaging: add postinst for debian
* test: test debian packaging
* ci: fix the foder path
* chore: apt -> apt-get
* ci: verify debian package
* Revert "Revert "fix: improve the dbus security""
* fix: improve the portal config parsing
* Revert "fix: improve the dbus security"
* fix: improve the dbus security
* fix: free resources in slots
* chore: refine cmake files
* fix: support high DPI screen
------------------------------------------------------------------- -------------------------------------------------------------------
Sat May 14 11:21:14 UTC 2022 - k3vinyue@gmail.com - 1.4.4 Sat May 14 11:21:14 UTC 2022 - k3vinyue@gmail.com - 1.4.4

View File

@@ -1,5 +1,5 @@
Name: globalprotect-openconnect Name: globalprotect-openconnect
Version: 1.4.4 Version: 1.4.7
Release: 1 Release: 1
Summary: A GlobalProtect VPN client powered by OpenConnect Summary: A GlobalProtect VPN client powered by OpenConnect
Group: Productivity/Networking/PPP Group: Productivity/Networking/PPP

View File

@@ -1,7 +1,7 @@
#!/bin/bash -e #!/bin/bash -e
sudo apt update sudo apt-get update
sudo apt install -y \ sudo apt-get install -y \
build-essential \ build-essential \
qtbase5-dev \ qtbase5-dev \
libqt5websockets5-dev \ libqt5websockets5-dev \

View File

@@ -0,0 +1,17 @@
#!/bin/bash -e
sudo apt-get update
sudo apt-get install -y \
build-essential \
qtbase5-dev \
libqt5websockets5-dev \
qtwebengine5-dev \
cmake \
debhelper
mkdir -p build
cp ./artifacts/*.tar.gz build/ && cd build
tar -xzf *.tar.gz && cd globalprotect-openconnect-*/
dpkg-buildpackage -us -uc