mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
98e641e99d | ||
|
6fa77cdbd2 | ||
|
64e6487e7e | ||
|
e8b2c1606f |
5
.github/workflows/pre-release.yml
vendored
5
.github/workflows/pre-release.yml
vendored
@@ -1,10 +1,7 @@
|
||||
name: Pre Release
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Build"]
|
||||
branches: [master]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
pre-release:
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
using namespace gpclient::helper;
|
||||
|
||||
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, const GatewayAuthenticatorParams& params)
|
||||
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, const GatewayAuthenticatorParams params)
|
||||
: QObject()
|
||||
, gateway(gateway)
|
||||
, params(params)
|
||||
@@ -29,23 +29,19 @@ void GatewayAuthenticator::authenticate()
|
||||
{
|
||||
PLOGI << "Start gateway authentication...";
|
||||
|
||||
LoginParams loginParams;
|
||||
LoginParams loginParams { params.clientos() };
|
||||
loginParams.setUser(params.username());
|
||||
loginParams.setPassword(params.password());
|
||||
loginParams.setUserAuthCookie(params.userAuthCookie());
|
||||
|
||||
if (!params.clientos().isEmpty()) {
|
||||
loginParams.setClientos(params.clientos());
|
||||
}
|
||||
|
||||
login(loginParams);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::login(const LoginParams ¶ms)
|
||||
void GatewayAuthenticator::login(const LoginParams &loginParams)
|
||||
{
|
||||
PLOGI << "Trying to login the gateway at " << loginUrl << " with " << params.toUtf8();
|
||||
PLOGI << "Trying to login the gateway at " << loginUrl << " with " << loginParams.toUtf8();
|
||||
|
||||
QNetworkReply *reply = createRequest(loginUrl, params.toUtf8());
|
||||
QNetworkReply *reply = createRequest(loginUrl, loginParams.toUtf8());
|
||||
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onLoginFinished);
|
||||
}
|
||||
|
||||
@@ -132,10 +128,11 @@ void GatewayAuthenticator::onPerformNormalLogin(const QString &username, const Q
|
||||
PLOGI << "Start to perform normal login...";
|
||||
|
||||
normalLoginWindow->setProcessing(true);
|
||||
LoginParams params;
|
||||
params.setUser(username);
|
||||
params.setPassword(password);
|
||||
login(params);
|
||||
LoginParams loginParams { params.clientos() };
|
||||
loginParams.setUser(username);
|
||||
loginParams.setPassword(password);
|
||||
|
||||
login(loginParams);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onLoginWindowRejected()
|
||||
@@ -170,12 +167,12 @@ void GatewayAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> &saml
|
||||
PLOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
||||
}
|
||||
|
||||
LoginParams params;
|
||||
params.setUser(samlResult.value("username"));
|
||||
params.setPreloginCookie(samlResult.value("preloginCookie"));
|
||||
params.setUserAuthCookie(samlResult.value("userAuthCookie"));
|
||||
LoginParams loginParams { params.clientos() };
|
||||
loginParams.setUser(samlResult.value("username"));
|
||||
loginParams.setPreloginCookie(samlResult.value("preloginCookie"));
|
||||
loginParams.setUserAuthCookie(samlResult.value("userAuthCookie"));
|
||||
|
||||
login(params);
|
||||
login(loginParams);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onSAMLLoginFail(const QString msg)
|
||||
|
@@ -10,7 +10,7 @@ class GatewayAuthenticator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GatewayAuthenticator(const QString& gateway, const GatewayAuthenticatorParams& params);
|
||||
explicit GatewayAuthenticator(const QString& gateway, const GatewayAuthenticatorParams params);
|
||||
~GatewayAuthenticator();
|
||||
|
||||
void authenticate();
|
||||
@@ -30,13 +30,13 @@ private slots:
|
||||
|
||||
private:
|
||||
QString gateway;
|
||||
const GatewayAuthenticatorParams& params;
|
||||
const GatewayAuthenticatorParams params;
|
||||
QString preloginUrl;
|
||||
QString loginUrl;
|
||||
|
||||
NormalLoginWindow *normalLoginWindow{ nullptr };
|
||||
|
||||
void login(const LoginParams& params);
|
||||
void login(const LoginParams& loginParams);
|
||||
void doAuth();
|
||||
void normalAuth(QString labelUsername, QString labelPassword, QString authMessage);
|
||||
void samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl = "");
|
||||
|
@@ -50,7 +50,7 @@ GPClient::~GPClient()
|
||||
void GPClient::setupSettings()
|
||||
{
|
||||
settingsButton = new QPushButton(this);
|
||||
settingsButton->setIcon(QIcon(":/images/settings_icon.svg"));
|
||||
settingsButton->setIcon(QIcon(":/images/settings_icon.png"));
|
||||
settingsButton->setFixedSize(QSize(28, 28));
|
||||
|
||||
QRect rect = this->geometry();
|
||||
@@ -68,7 +68,7 @@ void GPClient::setupSettings()
|
||||
void GPClient::onSettingsButtonClicked()
|
||||
{
|
||||
settingsDialog->setExtraArgs(settings::get("extraArgs", "").toString());
|
||||
settingsDialog->setClientos(settings::get("clientos", "").toString());
|
||||
settingsDialog->setClientos(settings::get("clientos", "Linux").toString());
|
||||
settingsDialog->show();
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ void GPClient::doConnect()
|
||||
// Login to the portal interface to get the portal config and preferred gateway
|
||||
void GPClient::portalLogin()
|
||||
{
|
||||
PortalAuthenticator *portalAuth = new PortalAuthenticator(portal(), settings::get("clientos", "").toString());
|
||||
PortalAuthenticator *portalAuth = new PortalAuthenticator(portal(), settings::get("clientos", "Linux").toString());
|
||||
|
||||
connect(portalAuth, &PortalAuthenticator::success, this, &GPClient::onPortalSuccess);
|
||||
// Prelogin failed on the portal interface, try to treat the portal as a gateway interface
|
||||
@@ -356,7 +356,7 @@ void GPClient::gatewayLogin()
|
||||
PLOGI << "Performing gateway login...";
|
||||
|
||||
GatewayAuthenticatorParams params = GatewayAuthenticatorParams::fromPortalConfigResponse(portalConfig);
|
||||
params.setClientos(settings::get("clientos", "").toString());
|
||||
params.setClientos(settings::get("clientos", "Linux").toString());
|
||||
|
||||
GatewayAuthenticator *gatewayAuth = new GatewayAuthenticator(currentGateway().address(), params);
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QUrlQuery>
|
||||
|
||||
LoginParams::LoginParams()
|
||||
LoginParams::LoginParams(const QString clientos)
|
||||
{
|
||||
params.addQueryItem("prot", QUrl::toPercentEncoding("https:"));
|
||||
params.addQueryItem("server", "");
|
||||
@@ -15,6 +15,12 @@ LoginParams::LoginParams()
|
||||
params.addQueryItem("direct", "yes");
|
||||
params.addQueryItem("clientVer", "4100");
|
||||
params.addQueryItem("os-version", QUrl::toPercentEncoding(QSysInfo::prettyProductName()));
|
||||
|
||||
// add the clientos parameter if not empty
|
||||
if (!clientos.isEmpty()) {
|
||||
params.addQueryItem("clientos", clientos);
|
||||
}
|
||||
|
||||
params.addQueryItem("portal-userauthcookie", "");
|
||||
params.addQueryItem("portal-prelogonuserauthcookie", "");
|
||||
params.addQueryItem("prelogin-cookie", "");
|
||||
@@ -55,11 +61,6 @@ void LoginParams::setPreloginCookie(const QString cookie)
|
||||
updateQueryItem("prelogin-cookie", cookie);
|
||||
}
|
||||
|
||||
void LoginParams::setClientos(const QString clientos)
|
||||
{
|
||||
updateQueryItem("clientos", clientos);
|
||||
}
|
||||
|
||||
QByteArray LoginParams::toUtf8() const
|
||||
{
|
||||
return params.toString().toUtf8();
|
||||
|
@@ -6,7 +6,7 @@
|
||||
class LoginParams
|
||||
{
|
||||
public:
|
||||
LoginParams();
|
||||
LoginParams(const QString clientos);
|
||||
~LoginParams();
|
||||
|
||||
void setUser(const QString user);
|
||||
@@ -15,7 +15,6 @@ public:
|
||||
void setUserAuthCookie(const QString cookie);
|
||||
void setPrelogonAuthCookie(const QString cookie);
|
||||
void setPreloginCookie(const QString cookie);
|
||||
void setClientos(const QString clientos);
|
||||
|
||||
QByteArray toUtf8() const;
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include <plog/Log.h>
|
||||
#include <plog/Appenders/ColorConsoleAppender.h>
|
||||
|
||||
static const QString version = "v1.3.1";
|
||||
static const QString version = "v1.3.3";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@@ -14,6 +14,7 @@ using namespace gpclient::helper;
|
||||
|
||||
PortalAuthenticator::PortalAuthenticator(const QString& portal, const QString& clientos) : QObject()
|
||||
, portal(portal)
|
||||
, clientos(clientos)
|
||||
, preloginUrl("https://" + portal + "/global-protect/prelogin.esp?tmp=tmp&kerberos-support=yes&ipv6-support=yes&clientVer=4100")
|
||||
, configUrl("https://" + portal + "/global-protect/getconfig.esp")
|
||||
{
|
||||
@@ -146,12 +147,12 @@ void PortalAuthenticator::onSAMLLoginFail(const QString msg)
|
||||
|
||||
void PortalAuthenticator::fetchConfig(QString username, QString password, QString preloginCookie, QString userAuthCookie)
|
||||
{
|
||||
LoginParams params;
|
||||
params.setServer(portal);
|
||||
params.setUser(username);
|
||||
params.setPassword(password);
|
||||
params.setPreloginCookie(preloginCookie);
|
||||
params.setUserAuthCookie(userAuthCookie);
|
||||
LoginParams loginParams { clientos };
|
||||
loginParams.setServer(portal);
|
||||
loginParams.setUser(username);
|
||||
loginParams.setPassword(password);
|
||||
loginParams.setPreloginCookie(preloginCookie);
|
||||
loginParams.setUserAuthCookie(userAuthCookie);
|
||||
|
||||
// Save the username and password for future use.
|
||||
this->username = username;
|
||||
@@ -159,7 +160,7 @@ void PortalAuthenticator::fetchConfig(QString username, QString password, QStrin
|
||||
|
||||
PLOGI << "Fetching the portal config from " << configUrl << " for user: " << username;
|
||||
|
||||
QNetworkReply *reply = createRequest(configUrl, params.toUtf8());
|
||||
QNetworkReply *reply = createRequest(configUrl, loginParams.toUtf8());
|
||||
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onFetchConfigFinished);
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@ private slots:
|
||||
|
||||
private:
|
||||
QString portal;
|
||||
QString clientos;
|
||||
QString preloginUrl;
|
||||
QString configUrl;
|
||||
QString username;
|
||||
|
@@ -6,6 +6,6 @@
|
||||
<file>not_connected.png</file>
|
||||
<file>radio_unselected.png</file>
|
||||
<file>radio_selected.png</file>
|
||||
<file>settings_icon.svg</file>
|
||||
<file>settings_icon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
GPClient/settings_icon.png
Normal file
BIN
GPClient/settings_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
|
||||
<g>
|
||||
<path d="M16.5,19.9C16.5,19.9,16.5,19.9,16.5,19.9l3.1-3.1c0,0,0,0,0,0l2.3-2.3c2.2,0.6,4.5,0,6.2-1.6c1.8-1.8,2.3-4.4,1.4-6.8
|
||||
c-0.1-0.3-0.4-0.5-0.7-0.6c-0.3-0.1-0.7,0-0.9,0.3L25.6,8l-1.3-0.3L24,6.4l2.2-2.2c0.2-0.2,0.3-0.6,0.3-0.9
|
||||
c-0.1-0.3-0.3-0.6-0.6-0.7c-2.3-0.9-5-0.4-6.8,1.4c-1.6,1.6-2.2,4-1.6,6.2l-1.6,1.6l-2.6-2.6L11,5.3c-0.1-0.1-0.2-0.3-0.3-0.3
|
||||
L6.8,2.7C6.4,2.4,5.9,2.5,5.5,2.8L2.5,5.9C2.1,6.2,2.1,6.7,2.3,7.1L4.6,11c0.1,0.1,0.2,0.3,0.3,0.3l3.7,2.2l2.6,2.6l-1.2,1.2
|
||||
c-2.2-0.6-4.5,0-6.2,1.6c-1.8,1.8-2.3,4.4-1.4,6.8c0.1,0.3,0.4,0.5,0.7,0.6c0.3,0.1,0.7,0,0.9-0.3L6.4,24l1.3,0.3L8,25.6l-2.2,2.2
|
||||
c-0.2,0.2-0.3,0.6-0.3,0.9c0.1,0.3,0.3,0.6,0.6,0.7c0.8,0.3,1.5,0.4,2.3,0.4c1.6,0,3.3-0.6,4.5-1.9c1.6-1.6,2.2-4,1.6-6.2
|
||||
L16.5,19.9z"/>
|
||||
<path d="M22.5,16.8l-6,6l6.1,6.1c0.8,0.8,1.9,1.3,3,1.3s2.2-0.4,3-1.3c0.8-0.8,1.3-1.9,1.3-3c0-1.1-0.4-2.2-1.3-3L22.5,16.8z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user