From: Kevin Ottens Date: Thu, 11 Mar 2021 14:36:33 +0000 (+0100) Subject: Introduce an empty auth type X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~320^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0d3459e85e0b38133bd346634347b5b3a2e1459b;p=nextcloud-desktop.git Introduce an empty auth type This is necessary to be able to distinguish between "I decided on basic by default" and "I didn't write any auth type". To make sure all the jobs end up writing something we then implement the "I decided on basic by default" in the slots connected to the job and we assert it in checkAllDone() Signed-off-by: Kevin Ottens --- diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 3f5a05369..f41bbb9aa 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -920,6 +920,7 @@ void DetermineAuthTypeJob::start() oldFlowRequired->setIgnoreCredentialFailure(true); connect(get, &SimpleNetworkJob::finishedSignal, this, [this]() { + _resultGet = Basic; _getDone = true; checkAllDone(); }); @@ -927,8 +928,13 @@ void DetermineAuthTypeJob::start() auto authChallenge = reply->rawHeader("WWW-Authenticate").toLower(); if (authChallenge.contains("bearer ")) { _resultPropfind = OAuth; - } else if (authChallenge.isEmpty()) { - qCWarning(lcDetermineAuthTypeJob) << "Did not receive WWW-Authenticate reply to auth-test PROPFIND"; + } else { + if (authChallenge.isEmpty()) { + qCWarning(lcDetermineAuthTypeJob) << "Did not receive WWW-Authenticate reply to auth-test PROPFIND"; + } else { + qCWarning(lcDetermineAuthTypeJob) << "Unknown WWW-Authenticate reply to auth-test PROPFIND:" << authChallenge; + } + _resultPropfind = Basic; } _propfindDone = true; checkAllDone(); @@ -947,6 +953,8 @@ void DetermineAuthTypeJob::start() } } } + } else { + _resultOldFlow = Basic; } _oldFlowDone = true; checkAllDone(); @@ -962,6 +970,10 @@ void DetermineAuthTypeJob::checkAllDone() return; } + Q_ASSERT(_resultGet != NoAuthType); + Q_ASSERT(_resultPropfind != NoAuthType); + Q_ASSERT(_resultOldFlow != NoAuthType); + auto result = _resultPropfind; // WebViewFlow > OAuth > Basic diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index 99fd1d1f6..c9fd92fb2 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -437,6 +437,7 @@ class OWNCLOUDSYNC_EXPORT DetermineAuthTypeJob : public QObject Q_OBJECT public: enum AuthType { + NoAuthType, // used only before we got a chance to probe the server Basic, // also the catch-all fallback for backwards compatibility reasons OAuth, WebViewFlow, @@ -453,9 +454,9 @@ private: void checkAllDone(); AccountPtr _account; - AuthType _resultGet = Basic; - AuthType _resultPropfind = Basic; - AuthType _resultOldFlow = Basic; + AuthType _resultGet = NoAuthType; + AuthType _resultPropfind = NoAuthType; + AuthType _resultOldFlow = NoAuthType; bool _getDone = false; bool _propfindDone = false; bool _oldFlowDone = false;