summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/settings.h2
-rw-r--r--src/webview.cpp30
-rw-r--r--src/webview.h5
3 files changed, 30 insertions, 7 deletions
diff --git a/src/settings.h b/src/settings.h
index 4d8f04b..a218e3b 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -3,6 +3,7 @@
#include <QSettings>
#include <QDir>
+#include <QTextCodec>
#define CONFIG_FILE "/etc/lightdm/qt-lightdm-greeter.conf"
#define CONFIG_FOLDER "/etc/lightdm/qt-lightdm-greeter.conf.d"
@@ -59,6 +60,7 @@ public:
static QString guestSessionButtonText() { return s_settings->value("guest-session-button-text").toString(); }
static QString guestSessionStartText() { return s_settings->value("guest-session-start-text").toString(); }
static QString guestSessionStartButtonText() { return s_settings->value("guest-session-start-button-text").toString(); }
+ static QString allowedShibbolethDomains() { return s_settings->value("allowed-shibboleth-domains").toString(); }
static int resetForm() { return s_settings->value("reset-timeout", "30").toInt(); }
static int rpcPort() { return s_settings->value("rpc-port", "0").toInt(); }
};
diff --git a/src/webview.cpp b/src/webview.cpp
index 9ebc1ba..4fb8511 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -1,6 +1,7 @@
#include "webview.h"
#include "nam.h"
#include "global.h"
+#include "settings.h"
#include <QWebFrame>
#include <QNetworkReply>
@@ -14,6 +15,7 @@
#include <QWebElement>
#include <QRegularExpression>
#include <QWebPage>
+#include <QWebFrame>
static QRegularExpression urlListToRegExp(const QStringList &list);
@@ -32,13 +34,21 @@ QRegularExpression UaWebPage::re("(\\S+)$");
WebView::WebView(QWidget* parent)
: QWebView(parent),
- _timerAbortMessage(new QTimer(this)),
- _abortedDownload(false),
- _inErrorState(false),
- _timerReset(new QTimer(this)),
- _firstLoad(false)
+ _timerAbortMessage(new QTimer(this)),
+ _abortedDownload(false),
+ _inErrorState(false),
+ _timerReset(new QTimer(this)),
+ _firstLoad(false)
{
- this->setPage(new UaWebPage);
+ auto p = new UaWebPage;
+ if (!Settings::allowedShibbolethDomains().trimmed().isEmpty()) {
+ QObject::connect(p, &UaWebPage::frameCreated, [this](QWebFrame *frame) {
+ QObject::connect(frame, &QWebFrame::javaScriptWindowObjectCleared, [this, frame]() {
+ this->jsInjector(frame);
+ });
+ });
+ }
+ this->setPage(p);
_timerAbortMessage->setSingleShot(true);
_timerReset->setSingleShot(true);
connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
@@ -60,6 +70,14 @@ WebView::WebView(QWidget* parent)
connect(this, &QWebView::loadFinished, this, &WebView::onLoadFinished);
}
+void WebView::jsInjector(QWebFrame *frame)
+{
+ QString str = Settings::allowedShibbolethDomains().replace(
+ QRegularExpression("[^\\w. -]", QRegularExpression::UseUnicodePropertiesOption),
+ QStringLiteral(""));
+ frame->evaluateJavaScript(QStringLiteral("var slxIdpFilter ='") + str + QStringLiteral("'"));
+}
+
void WebView::windowCloseRequested()
{
// If we have an old URL stored on the stack, navigate back to it, otherwise we return and nothing happens
diff --git a/src/webview.h b/src/webview.h
index 98c596d..27ab2f7 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -7,6 +7,7 @@
class QNetworkReply;
class QTimer;
+class QWebFrame;
/**
* Make sure pages that want to load in a new tab are actually loaded in the same page,
@@ -17,7 +18,7 @@ class WebView : public QWebView
Q_OBJECT
public:
WebView(QWidget* parent = NULL);
- void reset(const QString baseUrl);
+ void reset(const QString baseUrl);
protected:
QWebView *createWindow(QWebPage::WebWindowType) override;
@@ -27,6 +28,8 @@ protected:
void resetTimeout();
+ void jsInjector(QWebFrame *frame);
+
signals:
void triggerReset(const QString &message);
void startAuthentication(const QString &user, const QString &pass);