mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Improve the authentication workflow (#18)
This commit is contained in:
@@ -243,6 +243,7 @@ void GPClient::portalLogin()
|
||||
connect(portalAuth, &PortalAuthenticator::success, this, &GPClient::onPortalSuccess);
|
||||
// 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::portalConfigFailed, this, &GPClient::onPortalConfigFail);
|
||||
// Portal login failed
|
||||
connect(portalAuth, &PortalAuthenticator::fail, this, &GPClient::onPortalFail);
|
||||
|
||||
@@ -251,21 +252,49 @@ void GPClient::portalLogin()
|
||||
portalAuth->authenticate();
|
||||
}
|
||||
|
||||
void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const GPGateway gateway, QList<GPGateway> allGateways)
|
||||
void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QString region)
|
||||
{
|
||||
PLOGI << "Portal authentication succeeded.";
|
||||
|
||||
this->portalConfig = portalConfig;
|
||||
// No gateway found in protal configuration
|
||||
if (portalConfig.allGateways().size() == 0) {
|
||||
PLOGI << "No gateway found in portal configuration, treat the portal address as a gateway.";
|
||||
tryGatewayLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
setAllGateways(allGateways);
|
||||
GPGateway gateway = filterPreferredGateway(portalConfig.allGateways(), region);
|
||||
setAllGateways(portalConfig.allGateways());
|
||||
setCurrentGateway(gateway);
|
||||
this->portalConfig = portalConfig;
|
||||
|
||||
gatewayLogin();
|
||||
}
|
||||
|
||||
void GPClient::onPortalPreloginFail()
|
||||
void GPClient::onPortalPreloginFail(const QString msg)
|
||||
{
|
||||
PLOGI << "Portal prelogin failed, try to preform login on the the gateway interface...";
|
||||
PLOGI << "Portal prelogin failed: " << msg;
|
||||
tryGatewayLogin();
|
||||
}
|
||||
|
||||
void GPClient::onPortalConfigFail(const QString msg)
|
||||
{
|
||||
PLOGI << "Failed to get the portal configuration, " << msg << " Treat the portal address as gateway.";
|
||||
tryGatewayLogin();
|
||||
}
|
||||
|
||||
void GPClient::onPortalFail(const QString &msg)
|
||||
{
|
||||
if (!msg.isEmpty()) {
|
||||
openMessageBox("Portal authentication failed.", msg);
|
||||
}
|
||||
|
||||
updateConnectionStatus(VpnStatus::disconnected);
|
||||
}
|
||||
|
||||
void GPClient::tryGatewayLogin()
|
||||
{
|
||||
PLOGI << "Try to preform login on the the gateway interface...";
|
||||
|
||||
// Treat the portal input as the gateway address
|
||||
GPGateway g;
|
||||
@@ -281,15 +310,6 @@ void GPClient::onPortalPreloginFail()
|
||||
gatewayLogin();
|
||||
}
|
||||
|
||||
void GPClient::onPortalFail(const QString &msg)
|
||||
{
|
||||
if (!msg.isEmpty()) {
|
||||
openMessageBox("Portal authentication failed.", msg);
|
||||
}
|
||||
|
||||
updateConnectionStatus(VpnStatus::disconnected);
|
||||
}
|
||||
|
||||
// Login to the gateway
|
||||
void GPClient::gatewayLogin()
|
||||
{
|
||||
|
Reference in New Issue
Block a user