mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Fix the clientos param (#87)
* fix the clientos param * fix the clientos param
This commit is contained in:
parent
64e6487e7e
commit
6fa77cdbd2
@ -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 = "");
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user