Compare commits

...

7 Commits

Author SHA1 Message Date
Philip J. Turmel
58071d92fc Merge a869a3ac9c into 939f2bd94a 2023-11-06 09:31:38 +08:00
Kevin Yue
939f2bd94a Merge pull request #263 from iamtalhaasghar/master
chores: update opensuse leap repo link
2023-11-06 09:31:14 +08:00
Talha Asghar
abffa21268 chores: update opensuse leap repo link
The old link is broken!
2023-11-04 09:55:26 +05:00
Philip J. Turmel
a869a3ac9c Add User Agent Override to SAML Authentication
Adds "samlUserAgent" key to settings dialog.  If left blank, prior
behavior is unchanged.

If provided, the WebView Profile is adjusted with ::setHttpUserAgent()
before opening the portal's SAML page.
2023-10-21 15:23:59 -04:00
Danilo Nascimento
705b03c0bb Fix: handshake failed by ERR_CERT_AUTHORITY_INVALID (#240) 2023-06-27 20:30:25 +08:00
Dimitri Papadopoulos Orfanos
7bef2ccc68 Fix typos found by codespell (#234) 2023-05-09 09:44:05 +08:00
Dmitry Mikushin
bffc5d733b Fixing binary paths array wrongly iterated up to binaryPaths->length() (#216) 2023-02-17 12:08:09 +08:00
21 changed files with 86 additions and 36 deletions

View File

@@ -17,6 +17,7 @@ add_executable(gpclient
cdpcommand.cpp
cdpcommandmanager.cpp
enhancedwebview.cpp
enhancedwebpage.cpp
gatewayauthenticator.cpp
gatewayauthenticatorparams.cpp
gpgateway.cpp

View File

@@ -0,0 +1,8 @@
#include "enhancedwebpage.h"
#include <QWebEngineCertificateError>
#include <plog/Log.h>
bool EnhancedWebPage::certificateError(const QWebEngineCertificateError &certificateError) {
LOGI << "An error occurred during certificate verification for " << certificateError.url().toString() << "; " << certificateError.errorDescription();
return certificateError.isOverridable();
};

View File

@@ -0,0 +1,12 @@
#ifndef ENHANCEDWEBPAGE_H
#define ENHANCEDWEBPAGE_H
#include <QtWebEngineWidgets/qwebenginepage.h>
class EnhancedWebPage : public QWebEnginePage
{
protected:
bool certificateError(const QWebEngineCertificateError &certificateError) override;
};
#endif // !ECHANCEDWEBPAG

View File

@@ -1,6 +1,7 @@
#include <QtCore/QProcessEnvironment>
#include <QtWebEngineWidgets/QWebEngineView>
#include "enhancedwebpage.h"
#include "enhancedwebview.h"
#include "cdpcommandmanager.h"
@@ -14,6 +15,7 @@ EnhancedWebView::EnhancedWebView(QWidget *parent)
void EnhancedWebView::initialize()
{
setPage(new EnhancedWebPage());
auto port = QProcessEnvironment::systemEnvironment().value(ENV_CDP_PORT);
cdp->initialize("http://127.0.0.1:" + port + "/json");
}

View File

@@ -64,4 +64,3 @@ void GatewayAuthenticatorParams::setInputStr(const QString &inputStr)
{
m_inputStr = inputStr;
}

View File

@@ -62,6 +62,7 @@ void GPClient::onSettingsButtonClicked()
{
settingsDialog->setClientos(settings::get("clientos", "Linux").toString());
settingsDialog->setOsVersion(settings::get("os-version", QSysInfo::prettyProductName()).toString());
settingsDialog->setSamlUserAgent(settings::get("samlUserAgent", "").toString());
settingsDialog->show();
}
@@ -69,6 +70,7 @@ void GPClient::onSettingsAccepted()
{
settings::save("clientos", settingsDialog->clientos());
settings::save("os-version", settingsDialog->osVersion());
settings::save("samlUserAgent", settingsDialog->samlUserAgent());
}
void GPClient::on_connectButton_clicked()
@@ -339,7 +341,7 @@ void GPClient::onPortalFail(const QString &msg)
void GPClient::tryGatewayLogin()
{
LOGI << "Try to preform login on the the gateway interface...";
LOGI << "Try to perform login on the the gateway interface...";
// Treat the portal input as the gateway address
GPGateway g;

View File

@@ -172,7 +172,7 @@ bool gpclient::helper::settings::secureGet(const QString &key, QString &value) {
if ( job.error() ) {
return false;
}
value = pw;
return true;
}
}

View File

@@ -31,7 +31,7 @@ namespace gpclient {
namespace settings {
extern QSettings *_settings;
static const QStringList reservedKeys {"extraArgs", "clientos"};
static const QStringList reservedKeys {"extraArgs", "clientos", "samlUserAgent"};
QVariant get(const QString &key, const QVariant &defaultValue = QVariant());
QStringList get_all(const QString &key, const QVariant &defaultValue = QVariant());

View File

@@ -32,7 +32,7 @@ void PortalAuthenticator::authenticate()
{
attempts++;
LOGI << QString("(%1/%2) attempts").arg(attempts).arg(MAX_ATTEMPTS) << ", preform portal prelogin at " << preloginUrl;
LOGI << QString("(%1/%2) attempts").arg(attempts).arg(MAX_ATTEMPTS) << ", perform portal prelogin at " << preloginUrl;
QNetworkReply *reply = createRequest(preloginUrl);
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onPreloginFinished);

View File

@@ -172,4 +172,3 @@ void PortalConfigResponse::setPrelogonUserAuthCookie(const QString cookie)
{
m_prelogonAuthCookie = cookie;
}

View File

@@ -4,8 +4,11 @@
#include <QWebEngineCookieStore>
#include <plog/Log.h>
#include "gphelper.h"
#include "samlloginwindow.h"
using namespace gpclient::helper;
SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
: QDialog(parent)
, webView(new EnhancedWebView(this))
@@ -42,6 +45,9 @@ void SAMLLoginWindow::closeEvent(QCloseEvent *event)
void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest, const QString preloginUrl)
{
webView->page()->profile()->cookieStore()->deleteSessionCookies();
const QString& ua = settings::get("samlUserAgent", "").toString();
if (!ua.isEmpty())
webView->page()->profile()->setHttpUserAgent(ua);
if (samlMethod == "POST") {
webView->setHtml(samlRequest, preloginUrl);

View File

@@ -40,3 +40,11 @@ void SettingsDialog::setOsVersion(QString osVersion) {
QString SettingsDialog::osVersion() {
return ui->osVersionInput->text();
}
void SettingsDialog::setSamlUserAgent(QString samlUserAgent) {
ui->samlUserAgentInput->setText(samlUserAgent);
}
QString SettingsDialog::samlUserAgent() {
return ui->samlUserAgentInput->text();
}

View File

@@ -24,6 +24,9 @@ public:
void setOsVersion(QString osVersion);
QString osVersion();
void setSamlUserAgent(QString samlUserAgent);
QString samlUserAgent();
private:
Ui::SettingsDialog *ui;
};

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>488</width>
<height>220</height>
<height>328</height>
</rect>
</property>
<property name="sizePolicy">
@@ -55,7 +55,17 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>os-version:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="osVersionInput"/>
</item>
<item row="4" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -65,13 +75,13 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="osVersionInput"/>
<item row="3" column="1">
<widget class="QLineEdit" name="samlUserAgentInput"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>os-version:</string>
<string>saml-user-agent:</string>
</property>
</widget>
</item>

View File

@@ -1,5 +1,5 @@
#include "vpn_json.h"
#include <QTextStream>
#include <QTextStream>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>

View File

@@ -34,9 +34,9 @@ GPService::~GPService()
QString GPService::findBinary()
{
for (int i = 0; i < binaryPaths->length(); i++) {
if (QFileInfo::exists(binaryPaths[i])) {
return binaryPaths[i];
for (auto& binaryPath : binaryPaths) {
if (QFileInfo::exists(binaryPath)) {
return binaryPath;
}
}
return nullptr;
@@ -136,7 +136,7 @@ void GPService::connect(QString server, QString username, QString passwd)
<< "--cookie-on-stdin"
<< server;
log("Start process with arugments: " + args.join(", "));
log("Start process with arguments: " + args.join(", "));
openconnect->start(bin, args);
openconnect->write((passwd + "\n").toUtf8());

View File

@@ -4,14 +4,13 @@
#include <QtCore/QObject>
#include <QtCore/QProcess>
static const QString binaryPaths[] {
"/usr/local/bin/openconnect",
"/usr/local/sbin/openconnect",
"/usr/bin/openconnect",
"/usr/sbin/openconnect",
"/opt/bin/openconnect",
"/opt/sbin/openconnect"
};
static QList<QString> binaryPaths = QList<QString>() <<
"/usr/local/bin/openconnect" <<
"/usr/local/sbin/openconnect" <<
"/usr/bin/openconnect" <<
"/usr/sbin/openconnect" <<
"/opt/bin/openconnect" <<
"/opt/sbin/openconnect";
class GPService : public QObject
{

View File

@@ -77,8 +77,9 @@ sudo dnf install globalprotect-openconnect
- openSUSE Leap
```sh
sudo zypper ar https://download.opensuse.org/repositories/home:/yuezk/openSUSE_Leap_15.2/home:yuezk.repo
```sh
sudo zypper ar https://download.opensuse.org/repositories/home:/yuezk/15.4/home:yuezk.repo
sudo zypper ref
sudo zypper install globalprotect-openconnect
```

4
cmakew
View File

@@ -36,7 +36,7 @@ fi
cmake_base="./.cmake"
cmake_bin="${cmake_base}/cmake-$cmake_version/bin/cmake"
# download cmake if neccessary
# download cmake if necessary
if [ ! -f "$cmake_bin" ]; then
download_link=""
@@ -99,4 +99,4 @@ if [ "$cygwin" = true ]; then
fi
# run cmake
exec "$cmake_bin" "$@"
exec "$cmake_bin" "$@"

4
debian/changelog vendored
View File

@@ -57,7 +57,7 @@ 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
* fix: fix bug of parsing the portal response
-- Kevin Yue <k3vinyue@gmail.com> Wed, 01 Jun 2022 23:55:50 +0800
@@ -70,7 +70,7 @@ globalprotect-openconnect (1.4.5-1) unstable; urgency=medium
* packaging: fix postinst for debian
* packaging: add postinst for debian
* test: test debian packaging
* ci: fix the foder path
* ci: fix the folder path
* chore: apt -> apt-get
* ci: verify debian package
* Revert "Revert "fix: improve the dbus security""

View File

@@ -25,7 +25,7 @@ Sun Jan 8 12:58:32 UTC 2023 - k3vinyue@gmail.com - 1.4.9
* Credentials autocompleting (secure version) (#179)
* Read all saved Gateways (for selecting in Systray) (#181)
* copy install script for debian (#180)
* add es and pt support to shange status when connected to vpn (#162)
* add es and pt support to change status when connected to vpn (#162)
* fix: improve the cli support
* feat: add --reset option to gpclient
@@ -59,7 +59,7 @@ 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
* fix: fix bug of parsing the portal response
-------------------------------------------------------------------
Sun May 29 13:15:40 UTC 2022 - k3vinyue@gmail.com - 1.4.5
@@ -72,7 +72,7 @@ Sun May 29 13:15:40 UTC 2022 - k3vinyue@gmail.com - 1.4.5
* packaging: fix postinst for debian
* packaging: add postinst for debian
* test: test debian packaging
* ci: fix the foder path
* ci: fix the folder path
* chore: apt -> apt-get
* ci: verify debian package
* Revert "Revert "fix: improve the dbus security""