mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Add User Agent Override to SAML Authentication
Adds "samlUserAgent" key to settings dialog. If left blank, prior behavior is unchanged. If provided, the WebView Profile is adjusted with ::setHttpUserAgent() before opening the portal's SAML page.
This commit is contained in:
parent
705b03c0bb
commit
a869a3ac9c
@ -62,6 +62,7 @@ void GPClient::onSettingsButtonClicked()
|
|||||||
{
|
{
|
||||||
settingsDialog->setClientos(settings::get("clientos", "Linux").toString());
|
settingsDialog->setClientos(settings::get("clientos", "Linux").toString());
|
||||||
settingsDialog->setOsVersion(settings::get("os-version", QSysInfo::prettyProductName()).toString());
|
settingsDialog->setOsVersion(settings::get("os-version", QSysInfo::prettyProductName()).toString());
|
||||||
|
settingsDialog->setSamlUserAgent(settings::get("samlUserAgent", "").toString());
|
||||||
settingsDialog->show();
|
settingsDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ void GPClient::onSettingsAccepted()
|
|||||||
{
|
{
|
||||||
settings::save("clientos", settingsDialog->clientos());
|
settings::save("clientos", settingsDialog->clientos());
|
||||||
settings::save("os-version", settingsDialog->osVersion());
|
settings::save("os-version", settingsDialog->osVersion());
|
||||||
|
settings::save("samlUserAgent", settingsDialog->samlUserAgent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::on_connectButton_clicked()
|
void GPClient::on_connectButton_clicked()
|
||||||
|
@ -31,7 +31,7 @@ namespace gpclient {
|
|||||||
namespace settings {
|
namespace settings {
|
||||||
|
|
||||||
extern QSettings *_settings;
|
extern QSettings *_settings;
|
||||||
static const QStringList reservedKeys {"extraArgs", "clientos"};
|
static const QStringList reservedKeys {"extraArgs", "clientos", "samlUserAgent"};
|
||||||
|
|
||||||
QVariant get(const QString &key, const QVariant &defaultValue = QVariant());
|
QVariant get(const QString &key, const QVariant &defaultValue = QVariant());
|
||||||
QStringList get_all(const QString &key, const QVariant &defaultValue = QVariant());
|
QStringList get_all(const QString &key, const QVariant &defaultValue = QVariant());
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
#include <QWebEngineCookieStore>
|
#include <QWebEngineCookieStore>
|
||||||
#include <plog/Log.h>
|
#include <plog/Log.h>
|
||||||
|
|
||||||
|
#include "gphelper.h"
|
||||||
#include "samlloginwindow.h"
|
#include "samlloginwindow.h"
|
||||||
|
|
||||||
|
using namespace gpclient::helper;
|
||||||
|
|
||||||
SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
|
SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, webView(new EnhancedWebView(this))
|
, webView(new EnhancedWebView(this))
|
||||||
@ -42,6 +45,9 @@ void SAMLLoginWindow::closeEvent(QCloseEvent *event)
|
|||||||
void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest, const QString preloginUrl)
|
void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest, const QString preloginUrl)
|
||||||
{
|
{
|
||||||
webView->page()->profile()->cookieStore()->deleteSessionCookies();
|
webView->page()->profile()->cookieStore()->deleteSessionCookies();
|
||||||
|
const QString& ua = settings::get("samlUserAgent", "").toString();
|
||||||
|
if (!ua.isEmpty())
|
||||||
|
webView->page()->profile()->setHttpUserAgent(ua);
|
||||||
|
|
||||||
if (samlMethod == "POST") {
|
if (samlMethod == "POST") {
|
||||||
webView->setHtml(samlRequest, preloginUrl);
|
webView->setHtml(samlRequest, preloginUrl);
|
||||||
|
@ -40,3 +40,11 @@ void SettingsDialog::setOsVersion(QString osVersion) {
|
|||||||
QString SettingsDialog::osVersion() {
|
QString SettingsDialog::osVersion() {
|
||||||
return ui->osVersionInput->text();
|
return ui->osVersionInput->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::setSamlUserAgent(QString samlUserAgent) {
|
||||||
|
ui->samlUserAgentInput->setText(samlUserAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SettingsDialog::samlUserAgent() {
|
||||||
|
return ui->samlUserAgentInput->text();
|
||||||
|
}
|
@ -24,6 +24,9 @@ public:
|
|||||||
void setOsVersion(QString osVersion);
|
void setOsVersion(QString osVersion);
|
||||||
QString osVersion();
|
QString osVersion();
|
||||||
|
|
||||||
|
void setSamlUserAgent(QString samlUserAgent);
|
||||||
|
QString samlUserAgent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog *ui;
|
Ui::SettingsDialog *ui;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>488</width>
|
<width>488</width>
|
||||||
<height>220</height>
|
<height>328</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -55,7 +55,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>os-version:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="osVersionInput"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -65,13 +75,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="osVersionInput"/>
|
<widget class="QLineEdit" name="samlUserAgentInput"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>os-version:</string>
|
<string>saml-user-agent:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user