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 | |
---|---|---|---|
|
e12613d9a4 | ||
|
86ad51b0ad | ||
|
1e2322b938 | ||
|
4313b9d0e7 |
@@ -10,7 +10,7 @@ using namespace gpclient::helper;
|
|||||||
|
|
||||||
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, const PortalConfigResponse& portalConfig)
|
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, const PortalConfigResponse& portalConfig)
|
||||||
: QObject()
|
: QObject()
|
||||||
, preloginUrl("https://" + gateway + "/ssl-vpn/prelogin.esp")
|
, preloginUrl("https://" + gateway + "/ssl-vpn/prelogin.esp?tmp=tmp&kerberos-support=yes&ipv6-support=yes&clientVer=4100&clientos=Linux")
|
||||||
, loginUrl("https://" + gateway + "/ssl-vpn/login.esp")
|
, loginUrl("https://" + gateway + "/ssl-vpn/login.esp")
|
||||||
, portalConfig(portalConfig)
|
, portalConfig(portalConfig)
|
||||||
{
|
{
|
||||||
@@ -151,11 +151,16 @@ void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QSt
|
|||||||
|
|
||||||
void GatewayAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> &samlResult)
|
void GatewayAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> &samlResult)
|
||||||
{
|
{
|
||||||
PLOGI << "SAML login succeeded, got the prelogin cookie " << samlResult.value("preloginCookie");
|
if (samlResult.contains("preloginCookie")) {
|
||||||
|
PLOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
||||||
|
} else {
|
||||||
|
PLOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
||||||
|
}
|
||||||
|
|
||||||
LoginParams params;
|
LoginParams params;
|
||||||
params.setUser(samlResult.value("username"));
|
params.setUser(samlResult.value("username"));
|
||||||
params.setPreloginCookie(samlResult.value("preloginCookie"));
|
params.setPreloginCookie(samlResult.value("preloginCookie"));
|
||||||
|
params.setUserAuthCookie(samlResult.value("userAuthCookie"));
|
||||||
|
|
||||||
login(params);
|
login(params);
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,8 @@
|
|||||||
#include <plog/Log.h>
|
#include <plog/Log.h>
|
||||||
#include <plog/Appenders/ColorConsoleAppender.h>
|
#include <plog/Appenders/ColorConsoleAppender.h>
|
||||||
|
|
||||||
|
static const QString version = "v1.2.2";
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const QDir path = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/GlobalProtect-openconnect";
|
const QDir path = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/GlobalProtect-openconnect";
|
||||||
@@ -17,6 +19,8 @@ int main(int argc, char *argv[])
|
|||||||
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
|
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
|
||||||
plog::init(plog::debug, logFile.toUtf8()).addAppender(&consoleAppender);
|
plog::init(plog::debug, logFile.toUtf8()).addAppender(&consoleAppender);
|
||||||
|
|
||||||
|
PLOGI << "GlobalProtect started, version: " << version;
|
||||||
|
|
||||||
QString port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
|
QString port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
|
||||||
|
|
||||||
if (port == "") {
|
if (port == "") {
|
||||||
|
@@ -14,7 +14,7 @@ using namespace gpclient::helper;
|
|||||||
|
|
||||||
PortalAuthenticator::PortalAuthenticator(const QString& portal) : QObject()
|
PortalAuthenticator::PortalAuthenticator(const QString& portal) : QObject()
|
||||||
, portal(portal)
|
, portal(portal)
|
||||||
, preloginUrl("https://" + portal + "/global-protect/prelogin.esp")
|
, preloginUrl("https://" + portal + "/global-protect/prelogin.esp?tmp=tmp&kerberos-support=yes&ipv6-support=yes&clientVer=4100&clientos=Linux")
|
||||||
, configUrl("https://" + portal + "/global-protect/getconfig.esp")
|
, configUrl("https://" + portal + "/global-protect/getconfig.esp")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -124,9 +124,13 @@ void PortalAuthenticator::samlAuth()
|
|||||||
|
|
||||||
void PortalAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> samlResult)
|
void PortalAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> samlResult)
|
||||||
{
|
{
|
||||||
PLOGI << "SAML login succeeded, got the prelogin cookie " << samlResult.value("preloginCookie");
|
if (samlResult.contains("preloginCookie")) {
|
||||||
|
PLOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
||||||
|
} else {
|
||||||
|
PLOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
||||||
|
}
|
||||||
|
|
||||||
fetchConfig(samlResult.value("username"), "", samlResult.value("preloginCookie"));
|
fetchConfig(samlResult.value("username"), "", samlResult.value("preloginCookie"), samlResult.value("userAuthCookie"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortalAuthenticator::onSAMLLoginFail(const QString msg)
|
void PortalAuthenticator::onSAMLLoginFail(const QString msg)
|
||||||
@@ -134,13 +138,14 @@ void PortalAuthenticator::onSAMLLoginFail(const QString msg)
|
|||||||
emitFail(msg);
|
emitFail(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortalAuthenticator::fetchConfig(QString username, QString password, QString preloginCookie)
|
void PortalAuthenticator::fetchConfig(QString username, QString password, QString preloginCookie, QString userAuthCookie)
|
||||||
{
|
{
|
||||||
LoginParams params;
|
LoginParams params;
|
||||||
params.setServer(portal);
|
params.setServer(portal);
|
||||||
params.setUser(username);
|
params.setUser(username);
|
||||||
params.setPassword(password);
|
params.setPassword(password);
|
||||||
params.setPreloginCookie(preloginCookie);
|
params.setPreloginCookie(preloginCookie);
|
||||||
|
params.setUserAuthCookie(userAuthCookie);
|
||||||
|
|
||||||
// Save the username and password for future use.
|
// Save the username and password for future use.
|
||||||
this->username = username;
|
this->username = username;
|
||||||
|
@@ -47,7 +47,7 @@ private:
|
|||||||
void tryAutoLogin();
|
void tryAutoLogin();
|
||||||
void normalAuth();
|
void normalAuth();
|
||||||
void samlAuth();
|
void samlAuth();
|
||||||
void fetchConfig(QString username, QString password, QString preloginCookie = "");
|
void fetchConfig(QString username, QString password, QString preloginCookie = "", QString userAuthCookie = "");
|
||||||
void emitFail(const QString& msg = "");
|
void emitFail(const QString& msg = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -59,22 +59,41 @@ void SAMLLoginWindow::onResponseReceived(QJsonObject params)
|
|||||||
|
|
||||||
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();
|
||||||
|
|
||||||
if (!username.isEmpty() && !preloginCookie.isEmpty()) {
|
LOGI << "Response received from " << response.value("url").toString();
|
||||||
|
|
||||||
|
if (!username.isEmpty()) {
|
||||||
|
LOGI << "Got username from SAML response headers " << username;
|
||||||
samlResult.insert("username", username);
|
samlResult.insert("username", username);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preloginCookie.isEmpty()) {
|
||||||
|
LOGI << "Got prelogin-cookie from SAML response headers " << preloginCookie;
|
||||||
samlResult.insert("preloginCookie", preloginCookie);
|
samlResult.insert("preloginCookie", preloginCookie);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void SAMLLoginWindow::onLoadFinished()
|
if (!userAuthCookie.isEmpty()) {
|
||||||
{
|
LOGI << "Got portal-userauthcookie from SAML response headers " << userAuthCookie;
|
||||||
LOGI << "Load finished " << this->webView->page()->url().toString();
|
samlResult.insert("userAuthCookie", userAuthCookie);
|
||||||
|
}
|
||||||
|
|
||||||
// Check the SAML result
|
// Check the SAML result
|
||||||
if (!samlResult.value("username").isEmpty() && !samlResult.value("preloginCookie").isEmpty()) {
|
if (samlResult.contains("username")
|
||||||
|
&& (samlResult.contains("preloginCookie") || samlResult.contains("userAuthCookie"))) {
|
||||||
|
LOGI << "Got the SAML authentication information successfully. "
|
||||||
|
<< "username: " << samlResult.value("username")
|
||||||
|
<< ", preloginCookie: " << samlResult.value("preloginCookie")
|
||||||
|
<< ", userAuthCookie: " << samlResult.value("userAuthCookie");
|
||||||
|
|
||||||
emit success(samlResult);
|
emit success(samlResult);
|
||||||
accept();
|
accept();
|
||||||
} else {
|
} else {
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SAMLLoginWindow::onLoadFinished()
|
||||||
|
{
|
||||||
|
LOGI << "Load finished " << this->webView->page()->url().toString();
|
||||||
|
}
|
||||||
|
@@ -7,10 +7,10 @@ A GlobalProtect VPN client (GUI) for Linux based on Openconnect and built with Q
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Similar user experience as the offical client in macOS.
|
- Similar user experience as the official client in macOS.
|
||||||
- Supports both SAML and non-SAML authentication modes.
|
- Supports both SAML and non-SAML authentication modes.
|
||||||
- Supports automatically selecting the preferred gateway from the multiple gateways.
|
- Supports automatically selecting the preferred gateway from the multiple gateways.
|
||||||
- Supports switching gateway manually.
|
- Supports switching gateway from the system tray menu manually.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user