mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Add support for okta saml login
This commit is contained in:
parent
cc59f031b0
commit
bdad3ffe4d
@ -80,13 +80,13 @@ void GPClient::preloginResultFinished()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray bytes = reply->readAll();
|
QByteArray xmlBytes = reply->readAll();
|
||||||
const QString tagMethod = "saml-auth-method";
|
const QString tagMethod = "saml-auth-method";
|
||||||
const QString tagRequest = "saml-request";
|
const QString tagRequest = "saml-request";
|
||||||
QString samlMethod;
|
QString samlMethod;
|
||||||
QString samlRequest;
|
QString samlRequest;
|
||||||
|
|
||||||
QXmlStreamReader xml(bytes);
|
QXmlStreamReader xml(xmlBytes);
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
xml.readNext();
|
xml.readNext();
|
||||||
if (xml.tokenType() == xml.StartElement) {
|
if (xml.tokenType() == xml.StartElement) {
|
||||||
@ -105,11 +105,7 @@ void GPClient::preloginResultFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (samlMethod == "POST") {
|
if (samlMethod == "POST") {
|
||||||
// TODO
|
samlLogin(reply->url().toString(), samlRequest);
|
||||||
emit connectFailed();
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText("TODO: SAML method is POST");
|
|
||||||
msgBox.exec();
|
|
||||||
} else if (samlMethod == "REDIRECT") {
|
} else if (samlMethod == "REDIRECT") {
|
||||||
samlLogin(samlRequest);
|
samlLogin(samlRequest);
|
||||||
}
|
}
|
||||||
@ -214,14 +210,14 @@ void GPClient::doAuth(const QString portal)
|
|||||||
connect(reply, &QNetworkReply::finished, this, &GPClient::preloginResultFinished);
|
connect(reply, &QNetworkReply::finished, this, &GPClient::preloginResultFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::samlLogin(const QString loginUrl)
|
void GPClient::samlLogin(const QString loginUrl, const QString html)
|
||||||
{
|
{
|
||||||
SAMLLoginWindow *loginWindow = new SAMLLoginWindow(this);
|
SAMLLoginWindow *loginWindow = new SAMLLoginWindow(this);
|
||||||
|
|
||||||
QObject::connect(loginWindow, &SAMLLoginWindow::success, this, &GPClient::onLoginSuccess);
|
QObject::connect(loginWindow, &SAMLLoginWindow::success, this, &GPClient::onLoginSuccess);
|
||||||
QObject::connect(loginWindow, &SAMLLoginWindow::rejected, this, &GPClient::connectFailed);
|
QObject::connect(loginWindow, &SAMLLoginWindow::rejected, this, &GPClient::connectFailed);
|
||||||
|
|
||||||
loginWindow->login(loginUrl);
|
loginWindow->login(loginUrl, html);
|
||||||
loginWindow->exec();
|
loginWindow->exec();
|
||||||
delete loginWindow;
|
delete loginWindow;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,6 @@ private:
|
|||||||
void moveCenter();
|
void moveCenter();
|
||||||
void updateConnectionStatus(QString status);
|
void updateConnectionStatus(QString status);
|
||||||
void doAuth(const QString portal);
|
void doAuth(const QString portal);
|
||||||
void samlLogin(const QString loginUrl);
|
void samlLogin(const QString loginUrl, const QString html = "");
|
||||||
};
|
};
|
||||||
#endif // GPCLIENT_H
|
#endif // GPCLIENT_H
|
||||||
|
@ -27,9 +27,13 @@ void SAMLLoginWindow::closeEvent(QCloseEvent *event)
|
|||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMLLoginWindow::login(QString url)
|
void SAMLLoginWindow::login(QString url, QString html)
|
||||||
{
|
{
|
||||||
webView->load(QUrl(url));
|
if (html == "") {
|
||||||
|
webView->load(QUrl(url));
|
||||||
|
} else {
|
||||||
|
webView->setHtml(html, url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMLLoginWindow::onResponseReceived(QJsonObject params)
|
void SAMLLoginWindow::onResponseReceived(QJsonObject params)
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
explicit SAMLLoginWindow(QWidget *parent = nullptr);
|
explicit SAMLLoginWindow(QWidget *parent = nullptr);
|
||||||
~SAMLLoginWindow();
|
~SAMLLoginWindow();
|
||||||
|
|
||||||
void login(QString url);
|
void login(QString url, QString html = "");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void success(QJsonObject samlResult);
|
void success(QJsonObject samlResult);
|
||||||
|
Loading…
Reference in New Issue
Block a user