[Pkg-owncloud-commits] [owncloud-client] 18/38: Always handle 401 requests, except for network jobs
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Sep 5 20:20:55 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch sid
in repository owncloud-client.
commit 1edf3dd5033cf7f38edbf5a306c9b6b5c497d165
Author: Daniel Molkentin <danimo at owncloud.com>
Date: Tue Aug 12 19:24:41 2014 +0200
Always handle 401 requests, except for network jobs
It is not enough to only implement it for the QNAM returned
by the ShibbolethCredentials, because we sometimes need it
when we have no valid credentials set (and are using dummy
credentials in the course). The main use case is the
Webview opened by Shibboleth for FBA.
But as a side-effect, we can use it to handle auth requests
from the updater and other places.
(cherry picked from commit 1544606bf0a883115e04f4409e3e2b30960dc1c9)
Conflicts:
src/CMakeLists.txt
src/creds/shibbolethcredentials.h
---
src/CMakeLists.txt | 2 +-
src/creds/shibbolethcredentials.cpp | 20 --------------
.../shibboleth => mirall}/authenticationdialog.cpp | 0
.../shibboleth => mirall}/authenticationdialog.h | 0
src/mirall/mirallaccessmanager.cpp | 32 ++++++++++++++++++++--
src/mirall/mirallaccessmanager.h | 2 ++
src/mirall/networkjobs.cpp | 1 +
7 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fbfd037..177e53e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -83,6 +83,7 @@ set(libsync_SRCS
mirall/folderman.cpp
mirall/folder.cpp
mirall/folderwatcher.cpp
+ mirall/authenticationdialog.cpp
mirall/syncresult.cpp
mirall/mirallconfigfile.cpp
mirall/syncengine.cpp
@@ -125,7 +126,6 @@ else()
creds/shibbolethcredentials.cpp
creds/shibboleth/shibbolethwebview.cpp
creds/shibboleth/shibbolethrefresher.cpp
- creds/shibboleth/authenticationdialog.cpp
creds/shibboleth/shibbolethuserjob.cpp
)
endif()
diff --git a/src/creds/shibbolethcredentials.cpp b/src/creds/shibbolethcredentials.cpp
index e3ad80b..ffbac81 100644
--- a/src/creds/shibbolethcredentials.cpp
+++ b/src/creds/shibbolethcredentials.cpp
@@ -20,7 +20,6 @@
#include <QDebug>
#include "creds/shibbolethcredentials.h"
-#include "creds/shibboleth/authenticationdialog.h"
#include "creds/shibboleth/shibbolethwebview.h"
#include "creds/shibboleth/shibbolethrefresher.h"
#include "creds/shibbolethcredentials.h"
@@ -173,8 +172,6 @@ QNetworkAccessManager* ShibbolethCredentials::getQNAM() const
QNetworkAccessManager* qnam(new MirallAccessManager);
connect(qnam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(slotReplyFinished(QNetworkReply*)));
- connect(qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
- SLOT(slotHandleAuthentication(QNetworkReply*,QAuthenticator*)));
return qnam;
}
@@ -319,23 +316,6 @@ void ShibbolethCredentials::invalidateAndFetch(Account* account)
job->start();
}
-void ShibbolethCredentials::slotHandleAuthentication(QNetworkReply *reply, QAuthenticator *authenticator)
-{
- Q_UNUSED(reply)
- QUrl url = reply->url();
- // show only scheme, host and port
- QUrl reducedUrl;
- reducedUrl.setScheme(url.scheme());
- reducedUrl.setHost(url.host());
- reducedUrl.setPort(url.port());
-
- AuthenticationDialog dialog(authenticator->realm(), reducedUrl.toString());
- if (dialog.exec() == QDialog::Accepted) {
- authenticator->setUser(dialog.user());
- authenticator->setPassword(dialog.password());
- }
-}
-
void ShibbolethCredentials::slotInvalidateAndFetchInvalidateDone(QKeychain::Job* job)
{
Account *account = qvariant_cast<Account*>(job->property("account"));
diff --git a/src/creds/shibboleth/authenticationdialog.cpp b/src/mirall/authenticationdialog.cpp
similarity index 100%
rename from src/creds/shibboleth/authenticationdialog.cpp
rename to src/mirall/authenticationdialog.cpp
diff --git a/src/creds/shibboleth/authenticationdialog.h b/src/mirall/authenticationdialog.h
similarity index 100%
rename from src/creds/shibboleth/authenticationdialog.h
rename to src/mirall/authenticationdialog.h
diff --git a/src/mirall/mirallaccessmanager.cpp b/src/mirall/mirallaccessmanager.cpp
index ddb9be0..ceb76b0 100644
--- a/src/mirall/mirallaccessmanager.cpp
+++ b/src/mirall/mirallaccessmanager.cpp
@@ -12,6 +12,7 @@
*/
#include <QNetworkRequest>
+#include <QNetworkReply>
#include <QNetworkProxy>
#include <QAuthenticator>
#include <QSslConfiguration>
@@ -19,6 +20,8 @@
#include "mirall/cookiejar.h"
#include "mirall/mirallaccessmanager.h"
#include "mirall/utility.h"
+#include "mirall/authenticationdialog.h"
+
namespace Mirall
{
@@ -33,8 +36,11 @@ MirallAccessManager::MirallAccessManager(QObject* parent)
setProxy(proxy);
#endif
setCookieJar(new CookieJar);
- QObject::connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
- this, SLOT(slotProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
+ connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
+ connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
+ this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
+
}
QNetworkReply* MirallAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData)
@@ -60,5 +66,27 @@ void MirallAccessManager::slotProxyAuthenticationRequired(const QNetworkProxy &p
authenticator->setPassword(proxy.password());
}
}
+void MirallAccessManager::slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
+{
+ // do not handle 401 created by the networkjobs. We may want
+ // to eventually exempt some, but for now we need
+ // it only for other things, e.g. the browser. Would we handle
+ // network jobs, this would break the wizard logic
+ if (reply->property("doNotHandleAuth").toBool()) {
+ return;
+ }
+ QUrl url = reply->url();
+ // show only scheme, host and port
+ QUrl reducedUrl;
+ reducedUrl.setScheme(url.scheme());
+ reducedUrl.setHost(url.host());
+ reducedUrl.setPort(url.port());
+
+ AuthenticationDialog dialog(authenticator->realm(), reducedUrl.toString());
+ if (dialog.exec() == QDialog::Accepted) {
+ authenticator->setUser(dialog.user());
+ authenticator->setPassword(dialog.password());
+ }
+}
} // ns Mirall
diff --git a/src/mirall/mirallaccessmanager.h b/src/mirall/mirallaccessmanager.h
index 149dd5a..e2d214d 100644
--- a/src/mirall/mirallaccessmanager.h
+++ b/src/mirall/mirallaccessmanager.h
@@ -31,6 +31,8 @@ protected:
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData = 0);
protected slots:
void slotProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
+ void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
+
};
} // ns Mirall
diff --git a/src/mirall/networkjobs.cpp b/src/mirall/networkjobs.cpp
index 4276245..520b854 100644
--- a/src/mirall/networkjobs.cpp
+++ b/src/mirall/networkjobs.cpp
@@ -57,6 +57,7 @@ void AbstractNetworkJob::setReply(QNetworkReply *reply)
if (_reply) {
_reply->deleteLater();
}
+ reply->setProperty("doNotHandleAuth", true);
_reply = reply;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list