forked from ports/kde-plasma-6
signon-plugin-oauth2: initial commit, version 0.25
This commit is contained in:
parent
223eb1cc90
commit
0fbdc72c39
10
signon-plugin-oauth2/.footprint
Normal file
10
signon-plugin-oauth2/.footprint
Normal file
@ -0,0 +1,10 @@
|
||||
drwxr-xr-x root/root usr/
|
||||
drwxr-xr-x root/root usr/include/
|
||||
drwxr-xr-x root/root usr/include/signon-plugins/
|
||||
-rw-r--r-- root/root usr/include/signon-plugins/oauth1data.h
|
||||
-rw-r--r-- root/root usr/include/signon-plugins/oauth2data.h
|
||||
drwxr-xr-x root/root usr/lib/
|
||||
drwxr-xr-x root/root usr/lib/pkgconfig/
|
||||
-rw-r--r-- root/root usr/lib/pkgconfig/signon-oauth2plugin.pc
|
||||
drwxr-xr-x root/root usr/lib/signon/
|
||||
-rwxr-xr-x root/root usr/lib/signon/liboauth2plugin.so
|
7
signon-plugin-oauth2/.signature
Normal file
7
signon-plugin-oauth2/.signature
Normal file
@ -0,0 +1,7 @@
|
||||
untrusted comment: verify with /etc/ports/kde-plasma-6.pub
|
||||
RWTGxEYrvi0p3hXwjQiO+uvmZss6ZW8uziRma7UjItptbADGJNBVpWZPyJ+/GFtCJBGkSCaLHS80vSNZVM1U+zA2XjVy90o6zQE=
|
||||
SHA256 (Pkgfile) = f8dbc67922a8677764e70296b8300b947a4e4952c82b32b3f8fc17e92cb1f58c
|
||||
SHA256 (.footprint) = 47af40481be1deb27c57f581c63e9d95b38a075752d0c14739e4c639e310448a
|
||||
SHA256 (signon-plugin-oauth2-VERSION_0.25.tar.bz2) = 04ce8d84f2beb29ca86399794519c2d0bbecf7c428fd9e6c01d7f3614a9ba98e
|
||||
SHA256 (sync.patch) = 5b11370647631254e803b304fa23f0716fe7a490b002e75400a740f8ef7e8410
|
||||
SHA256 (28.patch) = 64686b9e2003bb7b5576bfacf07f9039cbcb29a7749b593fca2d0b6608f4cf15
|
783
signon-plugin-oauth2/28.patch
Normal file
783
signon-plugin-oauth2/28.patch
Normal file
@ -0,0 +1,783 @@
|
||||
From d3ba6d4c19ca0b1081fbafc757d3c496cc21ada2 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 18:34:07 +0200
|
||||
Subject: [PATCH 01/10] Port QSignalSpys to PMF syntax
|
||||
|
||||
---
|
||||
tests/oauth2plugintest.cpp | 86 ++++++++++++++++----------------------
|
||||
1 file changed, 37 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
|
||||
index 94e5c43..b257dc7 100644
|
||||
--- a/tests/oauth2plugintest.cpp
|
||||
+++ b/tests/oauth2plugintest.cpp
|
||||
@@ -244,7 +244,7 @@ void OAuth2PluginTest::testPluginCancel()
|
||||
m_testPlugin->cancel();
|
||||
|
||||
//then real cancel
|
||||
- QSignalSpy pluginError(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
+ QSignalSpy pluginError(m_testPlugin, &Plugin::error);
|
||||
|
||||
OAuth2PluginData userAgentData;
|
||||
userAgentData.setHost("https://localhost");
|
||||
@@ -435,11 +435,10 @@ void OAuth2PluginTest::testPluginProcess()
|
||||
QFETCH(QVariantMap, response);
|
||||
QFETCH(QVariantMap, stored);
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
- QSignalSpy store(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
+ QSignalSpy store(m_testPlugin, &Plugin::store);
|
||||
|
||||
m_testPlugin->process(sessionData, mechanism);
|
||||
if (errorCode < 0) {
|
||||
@@ -696,11 +695,10 @@ void OAuth2PluginTest::testPluginHmacSha1Process()
|
||||
QFETCH(QVariantMap, response);
|
||||
QFETCH(QVariantMap, stored);
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
- QSignalSpy store(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
+ QSignalSpy store(m_testPlugin, &Plugin::store);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -777,11 +775,10 @@ void OAuth2PluginTest::testPluginUseragentUserActionFinished()
|
||||
QStringList scopes = QStringList() << "scope1" << "scope2";
|
||||
data.setScope(scopes);
|
||||
|
||||
- QSignalSpy resultSpy(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
- QSignalSpy store(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)));
|
||||
+ QSignalSpy resultSpy(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
+ QSignalSpy store(m_testPlugin, &Plugin::store);
|
||||
|
||||
m_testPlugin->process(data, QString("user_agent"));
|
||||
|
||||
@@ -1286,10 +1283,9 @@ void OAuth2PluginTest::testPluginWebserverUserActionFinished()
|
||||
data.setScope(QStringList() << "one" << "two" << "three");
|
||||
data.setDisableStateParameter(disableStateParameter);
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1362,9 +1358,8 @@ void OAuth2PluginTest::testUserActionFinishedErrors()
|
||||
data.setClientSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
|
||||
data.setRedirectUri("http://localhost/resp.html");
|
||||
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
m_testPlugin->process(data, QString("web_server"));
|
||||
QTRY_COMPARE(userActionRequired.count(), 1);
|
||||
@@ -1486,10 +1481,9 @@ void OAuth2PluginTest::testOauth1UserActionFinished()
|
||||
data.setConsumerSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
|
||||
data.setRealm("MyHost");
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1610,9 +1604,8 @@ void OAuth2PluginTest::testOAuth2Errors()
|
||||
data.setClientSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
|
||||
data.setRedirectUri("http://localhost/resp.html");
|
||||
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1683,8 +1676,8 @@ void OAuth2PluginTest::testRefreshToken()
|
||||
|
||||
SignOn::UiSessionData info;
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1766,9 +1759,8 @@ void OAuth2PluginTest::testRefreshTokenError()
|
||||
|
||||
SignOn::UiSessionData info;
|
||||
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1842,10 +1834,9 @@ void OAuth2PluginTest::testClientAuthentication()
|
||||
data.setRedirectUri("http://localhost/resp.html");
|
||||
data.setForceClientAuthViaRequestBody(forceAuthViaRequestBody);
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1908,10 +1899,9 @@ void OAuth2PluginTest::testTokenPath()
|
||||
data.setClientId("104660106251471");
|
||||
data.setRedirectUri("http://localhost/resp.html");
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
TestNetworkAccessManager *nam = new TestNetworkAccessManager;
|
||||
m_testPlugin->m_networkAccessManager = nam;
|
||||
@@ -1995,10 +1985,9 @@ void OAuth2PluginTest::testTokenQuery()
|
||||
data.setClientId("104660106251471");
|
||||
data.setRedirectUri("http://localhost/resp.html");
|
||||
|
||||
- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
|
||||
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy result(m_testPlugin, &Plugin::result);
|
||||
+ QSignalSpy error(m_testPlugin, &Plugin::error);
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
QScopedPointer<TestNetworkAccessManager> nam(new TestNetworkAccessManager);
|
||||
m_testPlugin->m_networkAccessManager = nam.data();
|
||||
@@ -2062,8 +2051,7 @@ void OAuth2PluginTest::testOAuth2AuthRequestUri()
|
||||
QFETCH(QVariantMap, sessionData);
|
||||
QFETCH(QString, expectedUri);
|
||||
|
||||
- QSignalSpy userActionRequired(m_testPlugin,
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
|
||||
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
|
||||
|
||||
m_testPlugin->process(sessionData, mechanism);
|
||||
QCOMPARE(userActionRequired.count(), 1);
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From a0b372dfb6d37d0a81a545239128fec5ee94283c Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 18:51:29 +0200
|
||||
Subject: [PATCH 02/10] Port to new connection syntax
|
||||
|
||||
---
|
||||
example/oauthclient.cpp | 8 ++++----
|
||||
src/base-plugin.cpp | 12 ++++++------
|
||||
src/plugin.cpp | 18 ++++++------------
|
||||
tests/oauth2plugintest.cpp | 4 ++--
|
||||
4 files changed, 18 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/example/oauthclient.cpp b/example/oauthclient.cpp
|
||||
index adfcabf..328e8b7 100644
|
||||
--- a/example/oauthclient.cpp
|
||||
+++ b/example/oauthclient.cpp
|
||||
@@ -47,10 +47,10 @@ OAuthClient::~OAuthClient()
|
||||
void OAuthClient::authenticate()
|
||||
{
|
||||
SignOn::AuthSession *m_session = m_identity->createSession("oauth2");
|
||||
- QObject::connect(m_session, SIGNAL(response(const SignOn::SessionData &)),
|
||||
- this, SLOT(onResponse(const SignOn::SessionData &)));
|
||||
- QObject::connect(m_session, SIGNAL(error(const SignOn::Error &)),
|
||||
- this, SLOT(onError(const SignOn::Error &)));
|
||||
+ QObject::connect(m_session, &SignOn::AuthSession::response,
|
||||
+ this, &OAuthClient::onResponse);
|
||||
+ QObject::connect(m_session, &SignOn::AuthSession::error,
|
||||
+ this, &OAuthClient::onError);
|
||||
|
||||
OAuth2PluginData data;
|
||||
data.setHost("www.facebook.com");
|
||||
diff --git a/src/base-plugin.cpp b/src/base-plugin.cpp
|
||||
index aa2d639..d5ce81c 100644
|
||||
--- a/src/base-plugin.cpp
|
||||
+++ b/src/base-plugin.cpp
|
||||
@@ -124,12 +124,12 @@ void BasePlugin::postRequest(const QNetworkRequest &request,
|
||||
Q_D(BasePlugin);
|
||||
|
||||
d->m_reply = d->m_networkAccessManager->post(request, data);
|
||||
- connect(d->m_reply, SIGNAL(finished()),
|
||||
- this, SLOT(onPostFinished()));
|
||||
- connect(d->m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
- this, SLOT(onNetworkError(QNetworkReply::NetworkError)));
|
||||
- connect(d->m_reply, SIGNAL(sslErrors(QList<QSslError>)),
|
||||
- this, SLOT(handleSslErrors(QList<QSslError>)));
|
||||
+ connect(d->m_reply, &QNetworkReply::finished,
|
||||
+ this, &BasePlugin::onPostFinished);
|
||||
+ connect(d->m_reply, &QNetworkReply::error,
|
||||
+ this, &BasePlugin::onNetworkError);
|
||||
+ connect(d->m_reply, &QNetworkReply::sslErrors,
|
||||
+ this, &BasePlugin::handleSslErrors);
|
||||
}
|
||||
|
||||
void BasePlugin::serverReply(QNetworkReply *reply)
|
||||
diff --git a/src/plugin.cpp b/src/plugin.cpp
|
||||
index e6af807..c764609 100644
|
||||
--- a/src/plugin.cpp
|
||||
+++ b/src/plugin.cpp
|
||||
@@ -107,18 +107,12 @@ void Plugin::process(const SignOn::SessionData &inData,
|
||||
impl->setNetworkAccessManager(m_networkAccessManager);
|
||||
|
||||
// Forward the signals from the implementation
|
||||
- connect(impl, SIGNAL(result(const SignOn::SessionData &)),
|
||||
- SIGNAL(result(const SignOn::SessionData &)));
|
||||
- connect(impl, SIGNAL(store(const SignOn::SessionData &)),
|
||||
- SIGNAL(store(const SignOn::SessionData &)));
|
||||
- connect(impl, SIGNAL(error(const SignOn::Error &)),
|
||||
- SIGNAL(error(const SignOn::Error &)));
|
||||
- connect(impl, SIGNAL(userActionRequired(const SignOn::UiSessionData &)),
|
||||
- SIGNAL(userActionRequired(const SignOn::UiSessionData &)));
|
||||
- connect(impl, SIGNAL(refreshed(const SignOn::UiSessionData &)),
|
||||
- SIGNAL(refreshed(const SignOn::UiSessionData &)));
|
||||
- connect(impl, SIGNAL(statusChanged(const AuthPluginState, const QString&)),
|
||||
- SIGNAL(statusChanged(const AuthPluginState, const QString&)));
|
||||
+ connect(impl, &BasePlugin::result, this, &Plugin::result);
|
||||
+ connect(impl, &BasePlugin::store, this, &Plugin::store);
|
||||
+ connect(impl, &BasePlugin::error, this, &Plugin::error);
|
||||
+ connect(impl, &BasePlugin::userActionRequired, this, &Plugin::userActionRequired);
|
||||
+ connect(impl, &BasePlugin::refreshed, this, &Plugin::refreshed);
|
||||
+ connect(impl, &BasePlugin::statusChanged, this, &Plugin::statusChanged);
|
||||
|
||||
impl->process(inData, mechanism);
|
||||
}
|
||||
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
|
||||
index b257dc7..9e16950 100644
|
||||
--- a/tests/oauth2plugintest.cpp
|
||||
+++ b/tests/oauth2plugintest.cpp
|
||||
@@ -142,8 +142,8 @@ public:
|
||||
open(ReadOnly | Unbuffered);
|
||||
setHeader(QNetworkRequest::ContentLengthHeader, QVariant(content.size()));
|
||||
|
||||
- QTimer::singleShot(0, this, SIGNAL(readyRead()));
|
||||
- QTimer::singleShot(10, this, SLOT(finish()));
|
||||
+ QTimer::singleShot(0, this, &TestNetworkReply::readyRead);
|
||||
+ QTimer::singleShot(10, this, &TestNetworkReply::finish);
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From 8211fd4a3ca31370069c6953db1589c1110dca90 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 18:59:12 +0200
|
||||
Subject: [PATCH 03/10] Port away from deprecated error() signal
|
||||
|
||||
---
|
||||
src/base-plugin.cpp | 7 ++++++-
|
||||
tests/oauth2plugintest.cpp | 8 +++++++-
|
||||
2 files changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/base-plugin.cpp b/src/base-plugin.cpp
|
||||
index d5ce81c..ffc8ad5 100644
|
||||
--- a/src/base-plugin.cpp
|
||||
+++ b/src/base-plugin.cpp
|
||||
@@ -126,8 +126,13 @@ void BasePlugin::postRequest(const QNetworkRequest &request,
|
||||
d->m_reply = d->m_networkAccessManager->post(request, data);
|
||||
connect(d->m_reply, &QNetworkReply::finished,
|
||||
this, &BasePlugin::onPostFinished);
|
||||
- connect(d->m_reply, &QNetworkReply::error,
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
+ connect(d->m_reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
|
||||
this, &BasePlugin::onNetworkError);
|
||||
+#else
|
||||
+ connect(d->m_reply, &QNetworkReply::errorOccurred,
|
||||
+ this, &BasePlugin::onNetworkError);
|
||||
+#endif
|
||||
connect(d->m_reply, &QNetworkReply::sslErrors,
|
||||
this, &BasePlugin::handleSslErrors);
|
||||
}
|
||||
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
|
||||
index 9e16950..f5221cc 100644
|
||||
--- a/tests/oauth2plugintest.cpp
|
||||
+++ b/tests/oauth2plugintest.cpp
|
||||
@@ -148,7 +148,13 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void finish() { setFinished(true); Q_EMIT finished(); }
|
||||
- void fail() { Q_EMIT error(error()); }
|
||||
+ void fail() {
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
+ Q_EMIT error(error());
|
||||
+#else
|
||||
+ Q_EMIT errorOccurred(error());
|
||||
+#endif
|
||||
+ }
|
||||
|
||||
protected:
|
||||
void abort() Q_DECL_OVERRIDE {}
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From 039dab8db2e16d02872c6e12c698157e05dc43e2 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:02:04 +0200
|
||||
Subject: [PATCH 04/10] Port away from deprecated qrand
|
||||
|
||||
---
|
||||
src/oauth1plugin.cpp | 7 +++++++
|
||||
src/oauth2plugin.cpp | 6 ++++++
|
||||
2 files changed, 13 insertions(+)
|
||||
|
||||
diff --git a/src/oauth1plugin.cpp b/src/oauth1plugin.cpp
|
||||
index 8ec7645..6c38cbb 100644
|
||||
--- a/src/oauth1plugin.cpp
|
||||
+++ b/src/oauth1plugin.cpp
|
||||
@@ -94,8 +94,10 @@ public:
|
||||
{
|
||||
TRACE();
|
||||
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
// Initialize randomizer
|
||||
qsrand(QTime::currentTime().msec());
|
||||
+#endif
|
||||
}
|
||||
|
||||
~OAuth1PluginPrivate()
|
||||
@@ -437,8 +439,13 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
|
||||
.arg(urlEncode(inData.ConsumerKey())));
|
||||
authHeader.append(DELIMITER);
|
||||
// Nonce
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
unsigned long nonce1 = (unsigned long) qrand();
|
||||
unsigned long nonce2 = (unsigned long) qrand();
|
||||
+#else
|
||||
+ unsigned long nonce1 = QRandomGenerator::global()->generate64();
|
||||
+ unsigned long nonce2 = QRandomGenerator::global()->generate64();
|
||||
+#endif
|
||||
QString oauthNonce = QString("%1%2").arg(nonce1).arg(nonce2);
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_NONCE)
|
||||
.arg(urlEncode(oauthNonce)));
|
||||
diff --git a/src/oauth2plugin.cpp b/src/oauth2plugin.cpp
|
||||
index 418e7db..8763f00 100644
|
||||
--- a/src/oauth2plugin.cpp
|
||||
+++ b/src/oauth2plugin.cpp
|
||||
@@ -84,8 +84,10 @@ public:
|
||||
{
|
||||
TRACE();
|
||||
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
// Initialize randomizer
|
||||
qsrand(QTime::currentTime().msec());
|
||||
+#endif
|
||||
}
|
||||
|
||||
~OAuth2PluginPrivate()
|
||||
@@ -180,7 +182,11 @@ void OAuth2Plugin::sendOAuth2AuthRequest()
|
||||
QString redirectUri = d->m_oauth2Data.RedirectUri();
|
||||
query.addQueryItem(REDIRECT_URI, QUrl::toPercentEncoding(redirectUri));
|
||||
if (!d->m_oauth2Data.DisableStateParameter()) {
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
d->m_state = QString::number(qrand());
|
||||
+#else
|
||||
+ d->m_state = QString::number(QRandomGenerator::global()->generate());
|
||||
+#endif
|
||||
query.addQueryItem(STATE, d->m_state);
|
||||
}
|
||||
QStringList responseType = d->m_oauth2Data.ResponseType();
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From 47ff5a950e54ae2a570183be21312bcaa5271396 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:04:44 +0200
|
||||
Subject: [PATCH 05/10] Fix string concatenation in Qt6
|
||||
|
||||
---
|
||||
src/oauth1plugin.cpp | 33 ++++++++++++++++-----------------
|
||||
src/oauth1plugin.h | 2 +-
|
||||
src/oauth2plugin.cpp | 4 ++--
|
||||
src/oauth2plugin.h | 2 +-
|
||||
4 files changed, 20 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/src/oauth1plugin.cpp b/src/oauth1plugin.cpp
|
||||
index 6c38cbb..3a1bbd5 100644
|
||||
--- a/src/oauth1plugin.cpp
|
||||
+++ b/src/oauth1plugin.cpp
|
||||
@@ -60,7 +60,6 @@ const QString TIMESTAMP = QString("timestamp");
|
||||
const QString AUTH_ERROR = QString("error");
|
||||
|
||||
const QString EQUAL = QString("=");
|
||||
-const QString AMPERSAND = QString("&");
|
||||
const QString EQUAL_WITH_QUOTES = QString("%1=\"%2\"");
|
||||
const QString DELIMITER = QString(", ");
|
||||
const QString SPACE = QString(" ");
|
||||
@@ -321,7 +320,7 @@ void OAuth1Plugin::process(const SignOn::SessionData &inData,
|
||||
sendOAuth1PostRequest();
|
||||
}
|
||||
|
||||
-QString OAuth1Plugin::urlEncode(QString strData)
|
||||
+QByteArray OAuth1Plugin::urlEncode(QString strData)
|
||||
{
|
||||
return QUrl::toPercentEncoding(strData).constData();
|
||||
}
|
||||
@@ -399,7 +398,7 @@ QByteArray OAuth1Plugin::constructSignatureBaseString(const QString &aUrl,
|
||||
bool first = true;
|
||||
for (i = oAuthHeaderMap.begin(); i != oAuthHeaderMap.end(); ++i) {
|
||||
if(!first) {
|
||||
- oAuthHeaderString.append(AMPERSAND);
|
||||
+ oAuthHeaderString.append(QLatin1Char('&'));
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
@@ -411,9 +410,9 @@ QByteArray OAuth1Plugin::constructSignatureBaseString(const QString &aUrl,
|
||||
|
||||
QByteArray signatureBase;
|
||||
signatureBase.append("POST");
|
||||
- signatureBase.append(AMPERSAND);
|
||||
+ signatureBase.append('&');
|
||||
signatureBase.append(urlEncode(urlWithHostAndPath));
|
||||
- signatureBase.append(AMPERSAND);
|
||||
+ signatureBase.append('&');
|
||||
signatureBase.append(urlEncode(oAuthHeaderString));
|
||||
return signatureBase;
|
||||
}
|
||||
@@ -427,16 +426,16 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
|
||||
QString authHeader = OAUTH + SPACE;
|
||||
if (!inData.Realm().isEmpty()) {
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_REALM)
|
||||
- .arg(urlEncode(inData.Realm())));
|
||||
+ .arg(urlEncode(inData.Realm()).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
}
|
||||
if (!inData.Callback().isEmpty()) {
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_CALLBACK)
|
||||
- .arg(urlEncode(inData.Callback())));
|
||||
+ .arg(urlEncode(inData.Callback()).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
}
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_CONSUMERKEY)
|
||||
- .arg(urlEncode(inData.ConsumerKey())));
|
||||
+ .arg(urlEncode(inData.ConsumerKey()).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
// Nonce
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
@@ -448,32 +447,32 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
|
||||
#endif
|
||||
QString oauthNonce = QString("%1%2").arg(nonce1).arg(nonce2);
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_NONCE)
|
||||
- .arg(urlEncode(oauthNonce)));
|
||||
+ .arg(urlEncode(oauthNonce).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
// Timestamp
|
||||
QString oauthTimestamp =
|
||||
QString("%1").arg(QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_TIMESTAMP)
|
||||
- .arg(urlEncode(oauthTimestamp)));
|
||||
+ .arg(urlEncode(oauthTimestamp).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
if (!d->m_oauth1Token.isEmpty()) {
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_TOKEN)
|
||||
- .arg(urlEncode(d->m_oauth1Token)));
|
||||
+ .arg(urlEncode(d->m_oauth1Token).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
}
|
||||
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_SIGNATURE_METHOD)
|
||||
- .arg(urlEncode(d->m_mechanism)));
|
||||
+ .arg(urlEncode(d->m_mechanism).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
// Creating the signature
|
||||
// PLAINTEXT signature method
|
||||
QByteArray secretKey;
|
||||
- secretKey.append(urlEncode(inData.ConsumerSecret()) + AMPERSAND +
|
||||
+ secretKey.append(urlEncode(inData.ConsumerSecret()) + '&' +
|
||||
urlEncode(d->m_oauth1TokenSecret));
|
||||
if (d->m_mechanism == PLAINTEXT) {
|
||||
TRACE() << "Signature = " << secretKey;
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_SIGNATURE)
|
||||
- .arg(urlEncode(secretKey)));
|
||||
+ .arg(urlEncode(secretKey).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
}
|
||||
// HMAC-SHA1 signature method
|
||||
@@ -484,7 +483,7 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
|
||||
QByteArray signature = hashHMACSHA1(secretKey, signatureBase);
|
||||
TRACE() << "Signature = " << signature;
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_SIGNATURE)
|
||||
- .arg(urlEncode(signature.toBase64())));
|
||||
+ .arg(urlEncode(signature.toBase64()).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
}
|
||||
// TODO: RSA-SHA1 signature method should be implemented
|
||||
@@ -494,11 +493,11 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
|
||||
|
||||
if (!d->m_oauth1TokenVerifier.isEmpty()) {
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_VERIFIER)
|
||||
- .arg(urlEncode(d->m_oauth1TokenVerifier)));
|
||||
+ .arg(urlEncode(d->m_oauth1TokenVerifier).constData()));
|
||||
authHeader.append(DELIMITER);
|
||||
}
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_VERSION)
|
||||
- .arg(urlEncode(OAUTH_VERSION_1)));
|
||||
+ .arg(urlEncode(OAUTH_VERSION_1).constData()));
|
||||
|
||||
return authHeader;
|
||||
}
|
||||
diff --git a/src/oauth1plugin.h b/src/oauth1plugin.h
|
||||
index 3ff227a..aa37e26 100644
|
||||
--- a/src/oauth1plugin.h
|
||||
+++ b/src/oauth1plugin.h
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
const OAuth1PluginData &inData,
|
||||
const QString ×tamp,
|
||||
const QString &nonce);
|
||||
- QString urlEncode(QString strData);
|
||||
+ QByteArray urlEncode(QString strData);
|
||||
QString createOAuth1Header(const QString &aUrl, OAuth1PluginData inData);
|
||||
QByteArray hashHMACSHA1(const QByteArray &keyForHash ,const QByteArray &secret);
|
||||
OAuth1PluginTokenData oauth1responseFromMap(const QVariantMap &map);
|
||||
diff --git a/src/oauth2plugin.cpp b/src/oauth2plugin.cpp
|
||||
index 8763f00..c7f7f84 100644
|
||||
--- a/src/oauth2plugin.cpp
|
||||
+++ b/src/oauth2plugin.cpp
|
||||
@@ -393,9 +393,9 @@ void OAuth2Plugin::process(const SignOn::SessionData &inData,
|
||||
}
|
||||
}
|
||||
|
||||
-QString OAuth2Plugin::urlEncode(QString strData)
|
||||
+QByteArray OAuth2Plugin::urlEncode(QString strData)
|
||||
{
|
||||
- return QUrl::toPercentEncoding(strData).constData();
|
||||
+ return QUrl::toPercentEncoding(strData);
|
||||
}
|
||||
|
||||
void OAuth2Plugin::userActionFinished(const SignOn::UiSessionData &data)
|
||||
diff --git a/src/oauth2plugin.h b/src/oauth2plugin.h
|
||||
index a16c316..389d3c3 100644
|
||||
--- a/src/oauth2plugin.h
|
||||
+++ b/src/oauth2plugin.h
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
QVariantMap parseJSONReply(const QByteArray &reply);
|
||||
QVariantMap parseTextReply(const QByteArray &reply);
|
||||
void handleOAuth2Error(const QByteArray &reply);
|
||||
- QString urlEncode(QString strData);
|
||||
+ QByteArray urlEncode(QString strData);
|
||||
QUrl getAuthUrl();
|
||||
QUrl getTokenUrl();
|
||||
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From bef68f45e80c13501f836ec9d14aa3df682748e8 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:05:13 +0200
|
||||
Subject: [PATCH 06/10] Port away from deprecated QRegExp
|
||||
|
||||
---
|
||||
tests/oauth2plugintest.cpp | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
|
||||
index f5221cc..5cbbab2 100644
|
||||
--- a/tests/oauth2plugintest.cpp
|
||||
+++ b/tests/oauth2plugintest.cpp
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QPointer>
|
||||
-#include <QRegExp>
|
||||
+#include <QRegularExpression>
|
||||
#include <QScopedPointer>
|
||||
#include <QSignalSpy>
|
||||
#include <QTimer>
|
||||
@@ -749,7 +749,7 @@ void OAuth2PluginTest::testPluginHmacSha1Process()
|
||||
QString authorizationHeader =
|
||||
QString::fromUtf8(nam->m_lastRequest.rawHeader("Authorization"));
|
||||
QStringList authorizationHeaderParts =
|
||||
- authorizationHeader.split(QRegExp(",?\\s+"));
|
||||
+ authorizationHeader.split(QRegularExpression(",?\\s+"));
|
||||
QCOMPARE(authorizationHeaderParts[0], QString("OAuth"));
|
||||
|
||||
/* The rest of the header should be a mapping, let's parse it */
|
||||
@@ -1535,7 +1535,7 @@ void OAuth2PluginTest::testOauth1UserActionFinished()
|
||||
QString authorizationHeader =
|
||||
QString::fromUtf8(nam->m_lastRequest.rawHeader("Authorization"));
|
||||
QStringList authorizationHeaderParts =
|
||||
- authorizationHeader.split(QRegExp(",?\\s+"));
|
||||
+ authorizationHeader.split(QRegularExpression(",?\\s+"));
|
||||
QCOMPARE(authorizationHeaderParts[0], QString("OAuth"));
|
||||
|
||||
/* The rest of the header should be a mapping, let's parse it */
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From e9d3bdbd4eb8331a03b0c49d6b3a6c020db11c7f Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:06:05 +0200
|
||||
Subject: [PATCH 07/10] Build with C++17
|
||||
|
||||
Needed for Qt6
|
||||
---
|
||||
common-project-config.pri | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/common-project-config.pri b/common-project-config.pri
|
||||
index 1d5cdc6..dc9b95d 100644
|
||||
--- a/common-project-config.pri
|
||||
+++ b/common-project-config.pri
|
||||
@@ -8,7 +8,7 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
CONFIG += \
|
||||
- c++11 \
|
||||
+ c++17 \
|
||||
link_pkgconfig
|
||||
#MOC_DIR = .moc
|
||||
#OBJECTS_DIR = .obj
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From a275d6eacc71a1c0ac6a95e2c77a29b13e6c189e Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:10:17 +0200
|
||||
Subject: [PATCH 08/10] Use correct signon in example
|
||||
|
||||
---
|
||||
example/example.pro | 6 +-----
|
||||
1 file changed, 1 insertion(+), 5 deletions(-)
|
||||
|
||||
diff --git a/example/example.pro b/example/example.pro
|
||||
index 9b8ec65..1b2c6a8 100644
|
||||
--- a/example/example.pro
|
||||
+++ b/example/example.pro
|
||||
@@ -11,11 +11,7 @@ CONFIG += \
|
||||
link_pkgconfig
|
||||
QT -= gui
|
||||
|
||||
-lessThan(QT_MAJOR_VERSION, 5) {
|
||||
- PKGCONFIG += libsignon-qt
|
||||
-} else {
|
||||
- PKGCONFIG += libsignon-qt5
|
||||
-}
|
||||
+PKGCONFIG += libsignon-qt$$QT_MAJOR_VERSION
|
||||
|
||||
HEADERS += \
|
||||
oauthclient.h
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From 3ead61662e9b931ff2487869904c9be33cf97a85 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:13:10 +0200
|
||||
Subject: [PATCH 09/10] Port away from deprecated QString::SplitBehavior
|
||||
|
||||
---
|
||||
src/oauth2plugin.cpp | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/src/oauth2plugin.cpp b/src/oauth2plugin.cpp
|
||||
index c7f7f84..45510ad 100644
|
||||
--- a/src/oauth2plugin.cpp
|
||||
+++ b/src/oauth2plugin.cpp
|
||||
@@ -436,7 +436,11 @@ void OAuth2Plugin::userActionFinished(const SignOn::UiSessionData &data)
|
||||
} else if (pair.first == STATE) {
|
||||
state = pair.second;
|
||||
} else if (pair.first == SCOPE) {
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
respData.setScope(pair.second.split(' ', QString::SkipEmptyParts));
|
||||
+#else
|
||||
+ respData.setScope(pair.second.split(' ', Qt::SkipEmptyParts));
|
||||
+#endif
|
||||
} else {
|
||||
extraFields.insert(pair.first, pair.second);
|
||||
}
|
||||
@@ -587,7 +591,11 @@ void OAuth2Plugin::serverReply(QNetworkReply *reply)
|
||||
QStringList scope;
|
||||
if (map.contains(SCOPE)) {
|
||||
QString rawScope = QString::fromUtf8(map.take(SCOPE).toByteArray());
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
scope = rawScope.split(' ', QString::SkipEmptyParts);
|
||||
+#else
|
||||
+ scope = rawScope.split(' ', Qt::SkipEmptyParts);
|
||||
+#endif
|
||||
} else {
|
||||
scope = d->m_oauth2Data.Scope();
|
||||
}
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
From fab698862466994a8fdc9aa335c87b4f05430ce6 Mon Sep 17 00:00:00 2001
|
||||
From: Nicolas Fella <nicolas.fella@gmx.de>
|
||||
Date: Sun, 15 Oct 2023 19:15:56 +0200
|
||||
Subject: [PATCH 10/10] Port away from deprecated QList::toSet
|
||||
|
||||
---
|
||||
src/oauth2plugin.cpp | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/oauth2plugin.cpp b/src/oauth2plugin.cpp
|
||||
index 45510ad..0c23b99 100644
|
||||
--- a/src/oauth2plugin.cpp
|
||||
+++ b/src/oauth2plugin.cpp
|
||||
@@ -256,9 +256,15 @@ bool OAuth2Plugin::respondWithStoredToken(const QVariantMap &token,
|
||||
* we cannot use it now */
|
||||
if (!scopes.isEmpty()) {
|
||||
if (!token.contains(SCOPES)) return false;
|
||||
- QSet<QString> cachedScopes =
|
||||
- token.value(SCOPES).toStringList().toSet();
|
||||
+
|
||||
+ QStringList scopesList = token.value(SCOPES).toStringList();
|
||||
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
+ QSet<QString> cachedScopes = scopesList.toSet();
|
||||
if (!cachedScopes.contains(scopes.toSet())) return false;
|
||||
+#else
|
||||
+ QSet<QString> cachedScopes(scopesList.begin(), scopesList.end());
|
||||
+ if (!cachedScopes.contains(QSet(scopes.begin(), scopes.end()))) return false;
|
||||
+#endif
|
||||
}
|
||||
|
||||
if (token.contains(TOKEN)) {
|
||||
--
|
||||
GitLab
|
||||
|
31
signon-plugin-oauth2/Pkgfile
Normal file
31
signon-plugin-oauth2/Pkgfile
Normal file
@ -0,0 +1,31 @@
|
||||
# Description: OAuth 2 plugin for signon
|
||||
# URL: https://gitlab.com/accounts-sso/signon-plugin-oauth2
|
||||
# Maintainer: CRUX KDE Ports, kde-ports at crux dot nu
|
||||
# Depends on: signond
|
||||
|
||||
name=signon-plugin-oauth2
|
||||
version=0.25
|
||||
release=1
|
||||
source=(https://gitlab.com/nicolasfella/signon-plugin-oauth2/-/archive/VERSION_$version/$name-VERSION_$version.tar.bz2
|
||||
sync.patch
|
||||
28.patch)
|
||||
|
||||
build() {
|
||||
cd $name-VERSION_$version
|
||||
|
||||
patch -Np1 -i $SRC/sync.patch
|
||||
patch -Np1 -i $SRC/28.patch
|
||||
|
||||
sed -i -e 's/src tests/src/g' -i signon-oauth2.pro
|
||||
sed -i -e '/-Werror/d' common-project-config.pri
|
||||
|
||||
echo 'INSTALLS =' >>tests/tests.pro
|
||||
echo 'INSTALLS =' >>example/example.pr
|
||||
|
||||
qmake6 PREFIX=/usr LIBDIR=/usr/lib \
|
||||
QMAKE_CXXFLAGS+="-Wno-error=deprecated-declarations"
|
||||
CPPFLAGS="$CPPFLAGS -Wno-error" make
|
||||
make INSTALL_ROOT=$PKG install
|
||||
}
|
||||
|
||||
# vim: set ts=4 et:
|
456
signon-plugin-oauth2/sync.patch
Normal file
456
signon-plugin-oauth2/sync.patch
Normal file
@ -0,0 +1,456 @@
|
||||
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
|
||||
index 1cd9e9b..e3015b0 100644
|
||||
--- a/.gitlab-ci.yml
|
||||
+++ b/.gitlab-ci.yml
|
||||
@@ -1,4 +1,4 @@
|
||||
-image: ubuntu:xenial
|
||||
+image: ubuntu:bionic
|
||||
|
||||
cache:
|
||||
key: apt-cache
|
||||
diff --git a/README.md b/README.md
|
||||
index 24cc33c..4f174a4 100644
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -14,9 +14,10 @@ See COPYING file.
|
||||
Build instructions
|
||||
------------------
|
||||
|
||||
-This project depends on Qt 5 and [signond](https://gitlab.com/accounts-sso/signond). To build it, just run
|
||||
+This project depends on Qt 5.8 (or newer) and
|
||||
+[signond](https://gitlab.com/accounts-sso/signond). To build it, just run
|
||||
```
|
||||
qmake
|
||||
make
|
||||
make install
|
||||
-```
|
||||
\ No newline at end of file
|
||||
+```
|
||||
diff --git a/common-project-config.pri b/common-project-config.pri
|
||||
index e149d90..1d5cdc6 100644
|
||||
--- a/common-project-config.pri
|
||||
+++ b/common-project-config.pri
|
||||
@@ -19,13 +19,13 @@ UI_SOURCES_DIR = ui/src
|
||||
|
||||
QMAKE_CXXFLAGS += -fno-exceptions \
|
||||
-fno-rtti
|
||||
-# we don't like warnings...
|
||||
-unix:QMAKE_CXXFLAGS += -Werror
|
||||
|
||||
TOP_SRC_DIR = $$PWD
|
||||
|
||||
#DEFINES += QT_NO_DEBUG_OUTPUT
|
||||
-DEFINES += SIGNON_TRACE
|
||||
+DEFINES += \
|
||||
+ SIGNON_TRACE \
|
||||
+ QT_DISABLE_DEPRECATED_BEFORE=0x050900
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# setup the installation prefix
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index c6201a1..a65525e 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -33,6 +33,4 @@
|
||||
#define TRACE() if (0) qDebug()
|
||||
#endif
|
||||
|
||||
-#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
|
||||
-
|
||||
#endif // SIGNON_PLUGIN_OAUTH2_COMMON
|
||||
diff --git a/src/oauth1plugin.cpp b/src/oauth1plugin.cpp
|
||||
index 8892d62..8ec7645 100644
|
||||
--- a/src/oauth1plugin.cpp
|
||||
+++ b/src/oauth1plugin.cpp
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "oauth2tokendata.h"
|
||||
|
||||
#include <QUrl>
|
||||
+#include <QUrlQuery>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QDateTime>
|
||||
@@ -146,12 +147,14 @@ void OAuth1Plugin::sendOAuth1AuthRequest()
|
||||
Q_D(OAuth1Plugin);
|
||||
|
||||
QUrl url(d->m_oauth1Data.AuthorizationEndpoint());
|
||||
- url.addQueryItem(OAUTH_TOKEN, d->m_oauth1Token);
|
||||
+ QUrlQuery query(url);
|
||||
+ query.addQueryItem(OAUTH_TOKEN, d->m_oauth1Token);
|
||||
if (!d->m_oauth1ScreenName.isEmpty()) {
|
||||
// Prefill username for Twitter
|
||||
- url.addQueryItem(SCREEN_NAME, d->m_oauth1ScreenName);
|
||||
- url.addQueryItem(FORCE_LOGIN, d->m_oauth1ScreenName);
|
||||
+ query.addQueryItem(SCREEN_NAME, d->m_oauth1ScreenName);
|
||||
+ query.addQueryItem(FORCE_LOGIN, d->m_oauth1ScreenName);
|
||||
}
|
||||
+ url.setQuery(query);
|
||||
TRACE() << "URL = " << url.toString();
|
||||
SignOn::UiSessionData uiSession;
|
||||
uiSession.setOpenUrl(url.toString());
|
||||
@@ -195,7 +198,7 @@ bool OAuth1Plugin::respondWithStoredToken(const QVariantMap &token,
|
||||
timeToExpiry =
|
||||
token.value(EXPIRY).toUInt() +
|
||||
token.value(TIMESTAMP).toUInt() -
|
||||
- QDateTime::currentDateTime().toTime_t();
|
||||
+ QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
if (timeToExpiry < 0) {
|
||||
TRACE() << "Stored token is expired";
|
||||
return false;
|
||||
@@ -278,10 +281,10 @@ void OAuth1Plugin::process(const SignOn::SessionData &inData,
|
||||
if (!providedTokens.ScreenName().isNull())
|
||||
storeTokens.insert(SCREEN_NAME, providedTokens.ScreenName());
|
||||
|
||||
- d->m_oauth1Token = providedTokens.AccessToken().toAscii();
|
||||
- d->m_oauth1TokenSecret = providedTokens.TokenSecret().toAscii();
|
||||
- d->m_oauth1UserId = providedTokens.UserId().toAscii();
|
||||
- d->m_oauth1ScreenName = providedTokens.ScreenName().toAscii();
|
||||
+ d->m_oauth1Token = providedTokens.AccessToken().toLatin1();
|
||||
+ d->m_oauth1TokenSecret = providedTokens.TokenSecret().toLatin1();
|
||||
+ d->m_oauth1UserId = providedTokens.UserId().toLatin1();
|
||||
+ d->m_oauth1ScreenName = providedTokens.ScreenName().toLatin1();
|
||||
|
||||
OAuth2TokenData tokens;
|
||||
d->m_tokens.insert(d->m_key, QVariant::fromValue(storeTokens));
|
||||
@@ -365,9 +368,10 @@ QByteArray OAuth1Plugin::constructSignatureBaseString(const QString &aUrl,
|
||||
|
||||
QMap<QString, QString> oAuthHeaderMap;
|
||||
QUrl fullUrl(aUrl);
|
||||
+ QUrlQuery query(fullUrl);
|
||||
|
||||
// Constructing the base string as per RFC 5849. Sec 3.4.1
|
||||
- QList<QPair<QString, QString> > queryItems = fullUrl.queryItems();
|
||||
+ QList<QPair<QString, QString> > queryItems = query.queryItems();
|
||||
QPair<QString, QString> queryItem;
|
||||
foreach (queryItem, queryItems) {
|
||||
oAuthHeaderMap[queryItem.first] = queryItem.second;
|
||||
@@ -440,7 +444,8 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
|
||||
.arg(urlEncode(oauthNonce)));
|
||||
authHeader.append(DELIMITER);
|
||||
// Timestamp
|
||||
- QString oauthTimestamp = QString("%1").arg(QDateTime::currentDateTime().toTime_t());
|
||||
+ QString oauthTimestamp =
|
||||
+ QString("%1").arg(QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_TIMESTAMP)
|
||||
.arg(urlEncode(oauthTimestamp)));
|
||||
authHeader.append(DELIMITER);
|
||||
@@ -500,21 +505,21 @@ void OAuth1Plugin::userActionFinished(const SignOn::UiSessionData &data)
|
||||
TRACE() << data.UrlResponse();
|
||||
|
||||
// Checking if authorization server granted access
|
||||
- QUrl url = QUrl(data.UrlResponse());
|
||||
- if (url.hasQueryItem(AUTH_ERROR)) {
|
||||
+ QUrlQuery query(QUrl(data.UrlResponse()));
|
||||
+ if (query.hasQueryItem(AUTH_ERROR)) {
|
||||
TRACE() << "Server denied access permission";
|
||||
- emit error(Error(Error::NotAuthorized, url.queryItemValue(AUTH_ERROR)));
|
||||
+ emit error(Error(Error::NotAuthorized, query.queryItemValue(AUTH_ERROR)));
|
||||
return;
|
||||
}
|
||||
|
||||
- if (url.hasQueryItem(OAUTH_VERIFIER)) {
|
||||
- d->m_oauth1TokenVerifier = url.queryItemValue(OAUTH_VERIFIER);
|
||||
+ if (query.hasQueryItem(OAUTH_VERIFIER)) {
|
||||
+ d->m_oauth1TokenVerifier = query.queryItemValue(OAUTH_VERIFIER);
|
||||
d->m_oauth1Data.setCallback(QString());
|
||||
d->m_oauth1RequestType = OAUTH1_POST_ACCESS_TOKEN;
|
||||
sendOAuth1PostRequest();
|
||||
}
|
||||
- else if (url.hasQueryItem(OAUTH_PROBLEM)) {
|
||||
- handleOAuth1ProblemError(url.queryItemValue(OAUTH_PROBLEM));
|
||||
+ else if (query.hasQueryItem(OAUTH_PROBLEM)) {
|
||||
+ handleOAuth1ProblemError(query.queryItemValue(OAUTH_PROBLEM));
|
||||
}
|
||||
else {
|
||||
emit error(Error(Error::NotAuthorized, QString("oauth_verifier missing")));
|
||||
@@ -552,8 +557,8 @@ void OAuth1Plugin::serverReply(QNetworkReply *reply)
|
||||
const QMap<QString,QString> map = parseTextReply(replyContent);
|
||||
if (d->m_oauth1RequestType == OAUTH1_POST_REQUEST_TOKEN) {
|
||||
// Extracting the request token, token secret
|
||||
- d->m_oauth1Token = map.value(OAUTH_TOKEN).toAscii();
|
||||
- d->m_oauth1TokenSecret = map.value(OAUTH_TOKEN_SECRET).toAscii();
|
||||
+ d->m_oauth1Token = map.value(OAUTH_TOKEN).toLatin1();
|
||||
+ d->m_oauth1TokenSecret = map.value(OAUTH_TOKEN_SECRET).toLatin1();
|
||||
if (d->m_oauth1Token.isEmpty() ||
|
||||
!map.contains(OAUTH_TOKEN_SECRET)) {
|
||||
TRACE() << "OAuth request token is empty or secret is missing";
|
||||
@@ -565,8 +570,8 @@ void OAuth1Plugin::serverReply(QNetworkReply *reply)
|
||||
}
|
||||
else if (d->m_oauth1RequestType == OAUTH1_POST_ACCESS_TOKEN) {
|
||||
// Extracting the access token
|
||||
- d->m_oauth1Token = map.value(OAUTH_TOKEN).toAscii();
|
||||
- d->m_oauth1TokenSecret = map.value(OAUTH_TOKEN_SECRET).toAscii();
|
||||
+ d->m_oauth1Token = map.value(OAUTH_TOKEN).toLatin1();
|
||||
+ d->m_oauth1TokenSecret = map.value(OAUTH_TOKEN_SECRET).toLatin1();
|
||||
if (d->m_oauth1Token.isEmpty() ||
|
||||
!map.contains(OAUTH_TOKEN_SECRET)) {
|
||||
TRACE()<< "OAuth access token is empty or secret is missing";
|
||||
@@ -616,8 +621,8 @@ OAuth1Plugin::oauth1responseFromMap(const QVariantMap &map)
|
||||
|
||||
TRACE() << "Response:" << map;
|
||||
OAuth1PluginTokenData response(map);
|
||||
- response.setAccessToken(map[OAUTH_TOKEN].toString().toAscii());
|
||||
- response.setTokenSecret(map[OAUTH_TOKEN_SECRET].toString().toAscii());
|
||||
+ response.setAccessToken(map[OAUTH_TOKEN].toString().toLatin1());
|
||||
+ response.setTokenSecret(map[OAUTH_TOKEN_SECRET].toString().toLatin1());
|
||||
|
||||
// Store also (possible) user_id & screen_name
|
||||
if (map.contains(USER_ID)) {
|
||||
@@ -684,7 +689,7 @@ void OAuth1Plugin::sendOAuth1PostRequest()
|
||||
else {
|
||||
Q_ASSERT_X(false, __FUNCTION__, "Invalid OAuth1 POST request");
|
||||
}
|
||||
- request.setRawHeader(QByteArray("Authorization"), authHeader.toAscii());
|
||||
+ request.setRawHeader(QByteArray("Authorization"), authHeader.toLatin1());
|
||||
|
||||
postRequest(request, QByteArray());
|
||||
}
|
||||
diff --git a/src/oauth2plugin.cpp b/src/oauth2plugin.cpp
|
||||
index 57df6d8..418e7db 100644
|
||||
--- a/src/oauth2plugin.cpp
|
||||
+++ b/src/oauth2plugin.cpp
|
||||
@@ -175,22 +175,24 @@ void OAuth2Plugin::sendOAuth2AuthRequest()
|
||||
Q_D(OAuth2Plugin);
|
||||
|
||||
QUrl url = getAuthUrl();
|
||||
- url.addQueryItem(CLIENT_ID, d->m_oauth2Data.ClientId());
|
||||
+ QUrlQuery query(url);
|
||||
+ query.addQueryItem(CLIENT_ID, d->m_oauth2Data.ClientId());
|
||||
QString redirectUri = d->m_oauth2Data.RedirectUri();
|
||||
- url.addQueryItem(REDIRECT_URI, QUrl::toPercentEncoding(redirectUri));
|
||||
+ query.addQueryItem(REDIRECT_URI, QUrl::toPercentEncoding(redirectUri));
|
||||
if (!d->m_oauth2Data.DisableStateParameter()) {
|
||||
d->m_state = QString::number(qrand());
|
||||
- url.addQueryItem(STATE, d->m_state);
|
||||
+ query.addQueryItem(STATE, d->m_state);
|
||||
}
|
||||
QStringList responseType = d->m_oauth2Data.ResponseType();
|
||||
if (!responseType.isEmpty()) {
|
||||
- url.addQueryItem(RESPONSE_TYPE, responseType.join(" "));
|
||||
+ query.addQueryItem(RESPONSE_TYPE, responseType.join(" "));
|
||||
}
|
||||
QStringList scopes = d->m_oauth2Data.Scope();
|
||||
if (!scopes.isEmpty()) {
|
||||
// Passing list of scopes
|
||||
- url.addQueryItem(SCOPE, QUrl::toPercentEncoding(scopes.join(" ")));
|
||||
+ query.addQueryItem(SCOPE, QUrl::toPercentEncoding(scopes.join(" ")));
|
||||
}
|
||||
+ url.setQuery(query);
|
||||
TRACE() << "Url = " << url.toString();
|
||||
SignOn::UiSessionData uiSession;
|
||||
uiSession.setOpenUrl(url.toString());
|
||||
@@ -237,7 +239,7 @@ bool OAuth2Plugin::respondWithStoredToken(const QVariantMap &token,
|
||||
timeToExpiry =
|
||||
token.value(EXPIRY).toUInt() +
|
||||
token.value(TIMESTAMP).toUInt() -
|
||||
- QDateTime::currentDateTime().toTime_t();
|
||||
+ QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
if (timeToExpiry < 0) {
|
||||
TRACE() << "Stored token is expired";
|
||||
return false;
|
||||
@@ -400,9 +402,10 @@ void OAuth2Plugin::userActionFinished(const SignOn::UiSessionData &data)
|
||||
|
||||
// Checking if authorization server granted access
|
||||
QUrl url = QUrl(data.UrlResponse());
|
||||
- if (url.hasQueryItem(AUTH_ERROR)) {
|
||||
+ QUrlQuery query(url);
|
||||
+ if (query.hasQueryItem(AUTH_ERROR)) {
|
||||
TRACE() << "Server denied access permission";
|
||||
- emit error(Error(Error::NotAuthorized, url.queryItemValue(AUTH_ERROR)));
|
||||
+ emit error(Error(Error::NotAuthorized, query.queryItemValue(AUTH_ERROR)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -457,46 +460,42 @@ void OAuth2Plugin::userActionFinished(const SignOn::UiSessionData &data)
|
||||
// 2. Resource owner credentials (username, password)
|
||||
// 3. Assertion (assertion_type, assertion)
|
||||
// 4. Refresh Token (refresh_token)
|
||||
- QUrl newUrl;
|
||||
- QString query = d->m_oauth2Data.TokenQuery();
|
||||
- if (!query.isEmpty()) {
|
||||
- newUrl.setQuery(query);
|
||||
- }
|
||||
+ QUrlQuery tokenQuery(d->m_oauth2Data.TokenQuery());
|
||||
|
||||
- if (url.hasQueryItem(AUTH_CODE)) {
|
||||
+ if (query.hasQueryItem(AUTH_CODE)) {
|
||||
if (!d->m_oauth2Data.DisableStateParameter() &&
|
||||
- d->m_state != url.queryItemValue(STATE)) {
|
||||
+ d->m_state != query.queryItemValue(STATE)) {
|
||||
Q_EMIT error(Error(Error::NotAuthorized,
|
||||
QString("'state' parameter mismatch")));
|
||||
return;
|
||||
}
|
||||
- QString code = url.queryItemValue(AUTH_CODE);
|
||||
- newUrl.addQueryItem(GRANT_TYPE, AUTHORIZATION_CODE);
|
||||
- newUrl.addQueryItem(AUTH_CODE, code);
|
||||
- newUrl.addQueryItem(REDIRECT_URI, d->m_oauth2Data.RedirectUri());
|
||||
- sendOAuth2PostRequest(newUrl,
|
||||
+ QString code = query.queryItemValue(AUTH_CODE);
|
||||
+ tokenQuery.addQueryItem(GRANT_TYPE, AUTHORIZATION_CODE);
|
||||
+ tokenQuery.addQueryItem(AUTH_CODE, code);
|
||||
+ tokenQuery.addQueryItem(REDIRECT_URI, d->m_oauth2Data.RedirectUri());
|
||||
+ sendOAuth2PostRequest(tokenQuery,
|
||||
GrantType::AuthorizationCode);
|
||||
}
|
||||
- else if (url.hasQueryItem(USERNAME) && url.hasQueryItem(PASSWORD)) {
|
||||
- QString username = url.queryItemValue(USERNAME);
|
||||
- QString password = url.queryItemValue(PASSWORD);
|
||||
- newUrl.addQueryItem(GRANT_TYPE, USER_BASIC);
|
||||
- newUrl.addQueryItem(USERNAME, username);
|
||||
- newUrl.addQueryItem(PASSWORD, password);
|
||||
- sendOAuth2PostRequest(newUrl,
|
||||
+ else if (query.hasQueryItem(USERNAME) && query.hasQueryItem(PASSWORD)) {
|
||||
+ QString username = query.queryItemValue(USERNAME);
|
||||
+ QString password = query.queryItemValue(PASSWORD);
|
||||
+ tokenQuery.addQueryItem(GRANT_TYPE, USER_BASIC);
|
||||
+ tokenQuery.addQueryItem(USERNAME, username);
|
||||
+ tokenQuery.addQueryItem(PASSWORD, password);
|
||||
+ sendOAuth2PostRequest(tokenQuery,
|
||||
GrantType::UserBasic);
|
||||
}
|
||||
- else if (url.hasQueryItem(ASSERTION_TYPE) && url.hasQueryItem(ASSERTION)) {
|
||||
- QString assertion_type = url.queryItemValue(ASSERTION_TYPE);
|
||||
- QString assertion = url.queryItemValue(ASSERTION);
|
||||
- newUrl.addQueryItem(GRANT_TYPE, ASSERTION);
|
||||
- newUrl.addQueryItem(ASSERTION_TYPE, assertion_type);
|
||||
- newUrl.addQueryItem(ASSERTION, assertion);
|
||||
- sendOAuth2PostRequest(newUrl,
|
||||
+ else if (query.hasQueryItem(ASSERTION_TYPE) && query.hasQueryItem(ASSERTION)) {
|
||||
+ QString assertion_type = query.queryItemValue(ASSERTION_TYPE);
|
||||
+ QString assertion = query.queryItemValue(ASSERTION);
|
||||
+ tokenQuery.addQueryItem(GRANT_TYPE, ASSERTION);
|
||||
+ tokenQuery.addQueryItem(ASSERTION_TYPE, assertion_type);
|
||||
+ tokenQuery.addQueryItem(ASSERTION, assertion);
|
||||
+ sendOAuth2PostRequest(tokenQuery,
|
||||
GrantType::Assertion);
|
||||
}
|
||||
- else if (url.hasQueryItem(REFRESH_TOKEN)) {
|
||||
- QString refresh_token = url.queryItemValue(REFRESH_TOKEN);
|
||||
+ else if (query.hasQueryItem(REFRESH_TOKEN)) {
|
||||
+ QString refresh_token = query.queryItemValue(REFRESH_TOKEN);
|
||||
refreshOAuth2Token(refresh_token);
|
||||
}
|
||||
else {
|
||||
@@ -688,13 +687,13 @@ void OAuth2Plugin::handleOAuth2Error(const QByteArray &reply)
|
||||
void OAuth2Plugin::refreshOAuth2Token(const QString &refreshToken)
|
||||
{
|
||||
TRACE() << refreshToken;
|
||||
- QUrl url;
|
||||
- url.addQueryItem(GRANT_TYPE, REFRESH_TOKEN);
|
||||
- url.addQueryItem(REFRESH_TOKEN, refreshToken);
|
||||
- sendOAuth2PostRequest(url, GrantType::RefreshToken);
|
||||
+ QUrlQuery query;
|
||||
+ query.addQueryItem(GRANT_TYPE, REFRESH_TOKEN);
|
||||
+ query.addQueryItem(REFRESH_TOKEN, refreshToken);
|
||||
+ sendOAuth2PostRequest(query, GrantType::RefreshToken);
|
||||
}
|
||||
|
||||
-void OAuth2Plugin::sendOAuth2PostRequest(QUrl &postData,
|
||||
+void OAuth2Plugin::sendOAuth2PostRequest(QUrlQuery &postData,
|
||||
GrantType::e grantType)
|
||||
{
|
||||
Q_D(OAuth2Plugin);
|
||||
@@ -726,8 +725,8 @@ void OAuth2Plugin::sendOAuth2PostRequest(QUrl &postData,
|
||||
|
||||
d->m_grantType = grantType;
|
||||
|
||||
- TRACE() << "Query string = " << postData;
|
||||
- postRequest(request, postData.encodedQuery());
|
||||
+ TRACE() << "Query string = " << postData.query(QUrl::FullyDecoded);
|
||||
+ postRequest(request, postData.query(QUrl::FullyDecoded).toLatin1());
|
||||
}
|
||||
|
||||
void OAuth2Plugin::storeResponse(const OAuth2PluginTokenData &response)
|
||||
@@ -763,7 +762,7 @@ void OAuth2Plugin::storeResponse(const OAuth2PluginTokenData &response)
|
||||
if (response.ExpiresIn() > 0) {
|
||||
token.insert(EXPIRY, response.ExpiresIn());
|
||||
}
|
||||
- token.insert(TIMESTAMP, QDateTime::currentDateTime().toTime_t());
|
||||
+ token.insert(TIMESTAMP, QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
token.insert(SCOPES, d->m_oauth2Data.Scope());
|
||||
token.insert(EXTRA_FIELDS, response.ExtraFields());
|
||||
d->m_tokens.insert(d->m_key, QVariant::fromValue(token));
|
||||
diff --git a/src/oauth2plugin.h b/src/oauth2plugin.h
|
||||
index ce551df..a16c316 100644
|
||||
--- a/src/oauth2plugin.h
|
||||
+++ b/src/oauth2plugin.h
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "base-plugin.h"
|
||||
#include "oauth2data.h"
|
||||
|
||||
+class QUrlQuery;
|
||||
+
|
||||
namespace OAuth2PluginNS {
|
||||
|
||||
namespace GrantType {
|
||||
@@ -74,7 +76,7 @@ private:
|
||||
bool respondWithStoredToken(const QVariantMap &token,
|
||||
const QStringList &scopes);
|
||||
void refreshOAuth2Token(const QString &refreshToken);
|
||||
- void sendOAuth2PostRequest(QUrl &postData,
|
||||
+ void sendOAuth2PostRequest(QUrlQuery &postData,
|
||||
GrantType::e grantType);
|
||||
void storeResponse(const OAuth2PluginTokenData &response);
|
||||
QVariantMap parseReply(const QByteArray &contentType,
|
||||
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
|
||||
index 7d6f563..94e5c43 100644
|
||||
--- a/tests/oauth2plugintest.cpp
|
||||
+++ b/tests/oauth2plugintest.cpp
|
||||
@@ -320,7 +320,7 @@ void OAuth2PluginTest::testPluginProcess_data()
|
||||
QVariantMap token;
|
||||
token.insert("Token", QLatin1String("tokenfromtest"));
|
||||
token.insert("Token2", QLatin1String("token2fromtest"));
|
||||
- token.insert("timestamp", QDateTime::currentDateTime().toTime_t());
|
||||
+ token.insert("timestamp", QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
token.insert("Expiry", 10000);
|
||||
tokens.insert(QLatin1String("invalidid"), QVariant::fromValue(token));
|
||||
webServerData.m_data.insert(QLatin1String("Tokens"), tokens);
|
||||
@@ -545,7 +545,7 @@ void OAuth2PluginTest::testPluginHmacSha1Process_data()
|
||||
QVariantMap token;
|
||||
token.insert("oauth_token", QLatin1String("hmactokenfromtest"));
|
||||
token.insert("oauth_token_secret", QLatin1String("hmacsecretfromtest"));
|
||||
- token.insert("timestamp", QDateTime::currentDateTime().toTime_t());
|
||||
+ token.insert("timestamp", QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
token.insert("Expiry", (uint)50000);
|
||||
tokens.insert(QLatin1String("invalidid"), QVariant::fromValue(token));
|
||||
hmacSha1Data.m_data.insert(QLatin1String("Tokens"), tokens);
|
||||
@@ -591,7 +591,8 @@ void OAuth2PluginTest::testPluginHmacSha1Process_data()
|
||||
true << QVariantMap() << QVariantMap();
|
||||
hmacSha1Data.setForceTokenRefresh(false);
|
||||
|
||||
- token.insert("timestamp", QDateTime::currentDateTime().toTime_t() - 50000);
|
||||
+ token.insert("timestamp",
|
||||
+ QDateTime::currentDateTime().toSecsSinceEpoch() - 50000);
|
||||
token.insert("Expiry", (uint)100);
|
||||
tokens.insert(hmacSha1Data.ConsumerKey(), QVariant::fromValue(token));
|
||||
hmacSha1Data.m_data.insert(QLatin1String("Tokens"), tokens);
|
||||
@@ -1650,7 +1651,8 @@ void OAuth2PluginTest::testRefreshToken_data()
|
||||
QVariantMap tokens;
|
||||
QVariantMap token;
|
||||
token.insert("Token", QLatin1String("tokenfromtest"));
|
||||
- token.insert("timestamp", QDateTime::currentDateTime().toTime_t() - 10000);
|
||||
+ token.insert("timestamp",
|
||||
+ QDateTime::currentDateTime().toSecsSinceEpoch() - 10000);
|
||||
token.insert("Expiry", 1000);
|
||||
token.insert("refresh_token", QString("r3fr3sh"));
|
||||
tokens.insert(data.ClientId(), QVariant::fromValue(token));
|
||||
@@ -1665,7 +1667,7 @@ void OAuth2PluginTest::testRefreshToken_data()
|
||||
|
||||
QTest::newRow("expired access token") << data.toMap() << response;
|
||||
|
||||
- token.insert("timestamp", QDateTime::currentDateTime().toTime_t());
|
||||
+ token.insert("timestamp", QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
token.insert("Expiry", 50000);
|
||||
token.insert("ExtraFields", QVariantMap());
|
||||
tokens.insert(data.ClientId(), QVariant::fromValue(token));
|
||||
@@ -1755,7 +1757,8 @@ void OAuth2PluginTest::testRefreshTokenError()
|
||||
QVariantMap tokens;
|
||||
QVariantMap token;
|
||||
token.insert("Token", QLatin1String("tokenfromtest"));
|
||||
- token.insert("timestamp", QDateTime::currentDateTime().toTime_t() - 10000);
|
||||
+ token.insert("timestamp",
|
||||
+ QDateTime::currentDateTime().toSecsSinceEpoch() - 10000);
|
||||
token.insert("Expiry", 1000);
|
||||
token.insert("refresh_token", QString("r3fr3sh"));
|
||||
tokens.insert(data.ClientId(), QVariant::fromValue(token));
|
Loading…
Reference in New Issue
Block a user