Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI/LIBSYNC: force login flow V2 with config setting #6261

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/conffile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Some interesting values that can be set on the configuration file are:
| ``chunkSize`` | ``10000000`` (10 MB) | Specifies the chunk size of uploaded files in bytes. |
| | | The client will dynamically adjust this size within the maximum and minimum bounds (see below). |
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
| ``forceLoginV2`` | ``false`` | If the client should force the new login flow, eventhough some circumstances might need the old flow. |
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
| ``minChunkSize`` | ``1000000`` (1 MB) | Specifies the minimum chunk size of uploaded files in bytes. |
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
| ``maxChunkSize`` | ``1000000000`` (1000 MB) | Specifies the maximum chunk size of uploaded files in bytes. |
Expand Down
3 changes: 3 additions & 0 deletions src/gui/wizard/owncloudsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ int OwncloudSetupPage::nextId() const
return WizardCommon::Page_Flow2AuthCreds;
#ifdef WITH_WEBENGINE
case DetermineAuthTypeJob::WebViewFlow:
if (this->useFlow2) {
return WizardCommon::Page_Flow2AuthCreds;
}
return WizardCommon::Page_WebView;
#endif // WITH_WEBENGINE
case DetermineAuthTypeJob::NoAuthType:
Expand Down
3 changes: 3 additions & 0 deletions src/gui/wizard/owncloudsetuppage.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ protected slots:
QProgressIndicator *_progressIndi;
OwncloudWizard *_ocWizard;
AddCertificateDialog *addCertDial = nullptr;

// Grab the forceLoginV2-setting from the wizard
bool useFlow2 = _ocWizard->useFlow2();
};

} // namespace OCC
Expand Down
23 changes: 19 additions & 4 deletions src/gui/wizard/owncloudwizard.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/wizard/owncloudwizard.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/wizard/owncloudwizard.cpp

File src/gui/wizard/owncloudwizard.cpp does not conform to Custom style guidelines. (lines 290)
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Krzesimir Nowak <[email protected]>
*
Expand Down Expand Up @@ -65,7 +65,9 @@
setPage(WizardCommon::Page_Flow2AuthCreds, _flow2CredsPage);
setPage(WizardCommon::Page_AdvancedSetup, _advancedSetupPage);
#ifdef WITH_WEBENGINE
setPage(WizardCommon::Page_WebView, _webViewPage);
if (!useFlow2()) {
setPage(WizardCommon::Page_WebView, _webViewPage);
}
#endif // WITH_WEBENGINE

connect(this, &QDialog::finished, this, &OwncloudWizard::basicSetupFinished);
Expand All @@ -78,7 +80,9 @@
connect(_httpCredsPage, &OwncloudHttpCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
connect(_flow2CredsPage, &Flow2AuthCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
#ifdef WITH_WEBENGINE
connect(_webViewPage, &WebViewPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
if (!useFlow2()) {
connect(_webViewPage, &WebViewPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
}
#endif // WITH_WEBENGINE
connect(_advancedSetupPage, &OwncloudAdvancedSetupPage::createLocalAndRemoteFolders,
this, &OwncloudWizard::createLocalAndRemoteFolders);
Expand Down Expand Up @@ -189,6 +193,11 @@
return _advancedSetupPage->selectiveSyncBlacklist();
}

bool OwncloudWizard::useFlow2() const
{
return _useFlow2;
}

bool OwncloudWizard::useVirtualFileSync() const
{
return _advancedSetupPage->useVirtualFileSync();
Expand Down Expand Up @@ -235,7 +244,9 @@

#ifdef WITH_WEBENGINE
case WizardCommon::Page_WebView:
_webViewPage->setConnected();
if (!this->useFlow2()) {
_webViewPage->setConnected();
}
break;
#endif // WITH_WEBENGINE

Expand Down Expand Up @@ -276,7 +287,11 @@
_credentialsPage = _flow2CredsPage;
#ifdef WITH_WEBENGINE
} else if (type == DetermineAuthTypeJob::WebViewFlow) {
_credentialsPage = _webViewPage;
if(this->useFlow2()) {
_credentialsPage = _flow2CredsPage;
} else {
_credentialsPage = _webViewPage;
}
#endif // WITH_WEBENGINE
} else { // try Basic auth even for "Unknown"
_credentialsPage = _httpCredsPage;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/wizard/owncloudwizard.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/wizard/owncloudwizard.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/wizard/owncloudwizard.h

File src/gui/wizard/owncloudwizard.h does not conform to Custom style guidelines. (lines 24)
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Krzesimir Nowak <[email protected]>
*
Expand All @@ -21,6 +21,7 @@
#include <QSslKey>
#include <QSslCertificate>

#include "libsync/configfile.h"
#include "networkjobs.h"
#include "wizard/owncloudwizardcommon.h"
#include "accountfwd.h"
Expand Down Expand Up @@ -64,6 +65,7 @@
[[nodiscard]] QString ocUrl() const;
[[nodiscard]] QString localFolder() const;
[[nodiscard]] QStringList selectiveSyncBlacklist() const;
[[nodiscard]] bool useFlow2() const;
[[nodiscard]] bool useVirtualFileSync() const;
[[nodiscard]] bool isConfirmBigFolderChecked() const;

Expand Down Expand Up @@ -131,6 +133,8 @@

bool _registration = false;

bool _useFlow2 = ConfigFile().forceLoginV2();

friend class OwncloudSetupWizard;
};

Expand Down
12 changes: 12 additions & 0 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
static constexpr char confirmExternalStorageC[] = "confirmExternalStorage";
static constexpr char moveToTrashC[] = "moveToTrash";

static constexpr char forceLoginV2C[] = "forceLoginV2";

Check warning on line 107 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:107:23 [readability-static-definition-in-anonymous-namespace]

'forceLoginV2C' is a static definition in anonymous namespace; static is redundant here

static constexpr char certPath[] = "http_certificatePath";
static constexpr char certPasswd[] = "http_certificatePasswd";

Expand Down Expand Up @@ -991,6 +993,16 @@
setValue(moveToTrashC, isChecked);
}

bool ConfigFile::forceLoginV2() const
{
return getValue(forceLoginV2C, QString(), false).toBool();
}

void ConfigFile::setForceLoginV2(bool isChecked)
{
setValue(forceLoginV2C, isChecked);
}

bool ConfigFile::showMainDialogAsNormalWindow() const {
return getValue(showMainDialogAsNormalWindowC, {}, false).toBool();
}
Expand Down
4 changes: 4 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
[[nodiscard]] bool moveToTrash() const;
void setMoveToTrash(bool);

/** If we should force loginflow v2 */
[[nodiscard]] bool forceLoginV2() const;
void setForceLoginV2(bool);

[[nodiscard]] bool showMainDialogAsNormalWindow() const;

static bool setConfDir(const QString &value);
Expand Down
14 changes: 13 additions & 1 deletion src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/networkjobs.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/networkjobs.cpp

File src/libsync/networkjobs.cpp does not conform to Custom style guidelines. (lines 1082)
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Daniel Molkentin <[email protected]>
*
Expand Down Expand Up @@ -44,6 +44,7 @@

#include "creds/abstractcredentials.h"
#include "creds/httpcredentials.h"
#include "configfile.h"

namespace OCC {

Expand Down Expand Up @@ -1012,6 +1013,7 @@
: QObject(parent)
, _account(account)
{
useFlow2 = ConfigFile().forceLoginV2();
}

void DetermineAuthTypeJob::start()
Expand Down Expand Up @@ -1077,7 +1079,11 @@
if (flow != QJsonValue::Undefined) {
if (flow.toInt() == 1) {
#ifdef WITH_WEBENGINE
_resultOldFlow = WebViewFlow;
if(!this->useFlow2) {
_resultOldFlow = WebViewFlow;
} else {
qCWarning(lcDetermineAuthTypeJob) << "Server only supports flow1, but this client was configured to only use flow2";
}
#else // WITH_WEBENGINE
qCWarning(lcDetermineAuthTypeJob) << "Server does only support flow1, but this client was compiled without support for flow1";
#endif // WITH_WEBENGINE
Expand Down Expand Up @@ -1111,6 +1117,9 @@
// WebViewFlow > Basic
if (_account->serverVersionInt() >= Account::makeServerVersion(12, 0, 0)) {
result = WebViewFlow;
if (useFlow2) {
result = LoginFlowV2;
}
}
#endif // WITH_WEBENGINE

Expand All @@ -1123,6 +1132,9 @@
// If we determined that we need the webview flow (GS for example) then we switch to that
if (_resultOldFlow == WebViewFlow) {
result = WebViewFlow;
if (useFlow2) {
result = LoginFlowV2;
}
}
#endif // WITH_WEBENGINE

Expand Down
1 change: 1 addition & 0 deletions src/libsync/networkjobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ class OWNCLOUDSYNC_EXPORT DetermineAuthTypeJob : public QObject
bool _getDone = false;
bool _propfindDone = false;
bool _oldFlowDone = false;
bool useFlow2 = false;
};

/**
Expand Down
Loading