Skip to content
Open
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
3 changes: 0 additions & 3 deletions src/gui/newwizard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ target_sources(OpenCloudGui PRIVATE
jobs/resolveurljobfactory.cpp
jobs/resolveurljobfactory.h

jobs/discoverwebfingerservicejobfactory.cpp
jobs/discoverwebfingerservicejobfactory.h

jobs/webfingeruserinfojobfactory.cpp
jobs/webfingeruserinfojobfactory.h

Expand Down
101 changes: 0 additions & 101 deletions src/gui/newwizard/jobs/discoverwebfingerservicejobfactory.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions src/gui/newwizard/jobs/discoverwebfingerservicejobfactory.h

This file was deleted.

10 changes: 0 additions & 10 deletions src/gui/newwizard/setupwizardaccountbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@ QString SetupWizardAccountBuilder::syncTargetDir() const
return _defaultSyncTargetDir;
}

void SetupWizardAccountBuilder::setWebFingerAuthenticationServerUrl(const QUrl &url)
{
_webFingerAuthenticationServerUrl = url;
}

QUrl SetupWizardAccountBuilder::webFingerAuthenticationServerUrl() const
{
return _webFingerAuthenticationServerUrl;
}

void SetupWizardAccountBuilder::setWebFingerInstances(const QVector<QUrl> &instancesList)
{
_webFingerInstances = instancesList;
Expand Down
4 changes: 0 additions & 4 deletions src/gui/newwizard/setupwizardaccountbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ class SetupWizardAccountBuilder
*/
AccountPtr build() const;

void setWebFingerAuthenticationServerUrl(const QUrl &url);
QUrl webFingerAuthenticationServerUrl() const;

void setWebFingerInstances(const QVector<QUrl> &instancesList);
QVector<QUrl> webFingerInstances() const;

Expand All @@ -107,7 +104,6 @@ class SetupWizardAccountBuilder
private:
QUrl _serverUrl;

QUrl _webFingerAuthenticationServerUrl;
QVector<QUrl> _webFingerInstances;
QUrl _webFingerSelectedInstance;

Expand Down
39 changes: 13 additions & 26 deletions src/gui/newwizard/states/oauthcredentialssetupwizardstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ namespace OCC::Wizard {
OAuthCredentialsSetupWizardState::OAuthCredentialsSetupWizardState(SetupWizardContext *context)
: AbstractSetupWizardState(context)
{
const auto authServerUrl = [this]() {
auto authServerUrl = _context->accountBuilder().webFingerAuthenticationServerUrl();
if (!authServerUrl.isEmpty()) {
return authServerUrl;
}
return _context->accountBuilder().serverUrl();
}();

const auto authServerUrl = _context->accountBuilder().serverUrl();
auto oAuth = new OAuth(authServerUrl, _context->accessManager(), {}, this);
_page = new OAuthCredentialsSetupWizardPage(oAuth, authServerUrl);

Expand Down Expand Up @@ -59,33 +52,27 @@ OAuthCredentialsSetupWizardState::OAuthCredentialsSetupWizardState(SetupWizardCo
}
};

// SECOND WEBFINGER CALL (authenticated):
// This discovers which OpenCloud instance(s) the authenticated user has access to.
// Uses the OAuth bearer token and resource="acct:me@{host}".
// Looking for: rel="http://webfinger.opencloud/rel/server-instance"
// See issue #271 for why we perform WebFinger twice.
// Backend WebFinger docs: https://github.com/opencloud-eu/opencloud/blob/main/services/webfinger/README.md
if (!_context->accountBuilder().webFingerAuthenticationServerUrl().isEmpty()) {
auto *job = Jobs::WebFingerInstanceLookupJobFactory(_context->accessManager(), token).startJob(_context->accountBuilder().serverUrl(), this);
auto *job = Jobs::WebFingerInstanceLookupJobFactory(_context->accessManager(), token).startJob(_context->accountBuilder().serverUrl(), this);

connect(job, &CoreJob::finished, this, [finish, job, this]() {
if (!job->success()) {
Q_EMIT evaluationFailed(QStringLiteral("Failed to look up instances: %1").arg(job->errorMessage()));
} else {
const auto instanceUrls = qvariant_cast<QVector<QUrl>>(job->result());
connect(job, &CoreJob::finished, this, [finish, job, this]() {
if (!job->success()) {
Q_EMIT evaluationFailed(QStringLiteral("Failed to look up instances: %1").arg(job->errorMessage()));
} else {
const auto instanceUrls = qvariant_cast<QVector<QUrl>>(job->result());

if (instanceUrls.isEmpty()) {
Q_EMIT evaluationFailed(QStringLiteral("Server returned empty list of instances"));
} else {
_context->accountBuilder().setWebFingerInstances(instanceUrls);
}
if (instanceUrls.isEmpty()) {
Q_EMIT evaluationFailed(QStringLiteral("Server returned empty list of instances"));
} else {
_context->accountBuilder().setWebFingerInstances(instanceUrls);
}
}

finish();
});
} else {
finish();
}
});
});

// the implementation moves to the next state automatically once ready, no user interaction needed
Expand Down
19 changes: 1 addition & 18 deletions src/gui/newwizard/states/serverurlsetupwizardstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "gui/newwizard/states/serverurlsetupwizardstate.h"

#include "gui/newwizard/jobs/discoverwebfingerservicejobfactory.h"
#include "gui/newwizard/jobs/resolveurljobfactory.h"
#include "gui/newwizard/pages/serverurlsetupwizardpage.h"
#include "libsync/theme.h"
Expand Down Expand Up @@ -68,23 +67,7 @@ void ServerUrlSetupWizardState::evaluatePage()
}
_context->accountBuilder().setServerUrl(resolveJob->result().toUrl());

// FIRST WEBFINGER CALL (unauthenticated):
// This discovers if the server supports WebFinger-based authentication
// and finds the IdP URL. The resource parameter is the server URL itself.
// Looking for: rel="http://openid.net/specs/connect/1.0/issuer"
// See issue #271 for why we perform WebFinger twice.
// Backend WebFinger docs: https://github.com/opencloud-eu/opencloud/blob/main/services/webfinger/README.md
auto *checkWebFingerAuthJob =
Jobs::DiscoverWebFingerServiceJobFactory(_context->accessManager()).startJob(_context->accountBuilder().serverUrl(), this);
connect(checkWebFingerAuthJob, &CoreJob::finished, this, [checkWebFingerAuthJob, this]() {
// in case any kind of error occurs, we assume the WebFinger service is not available
if (!checkWebFingerAuthJob->success()) {
Q_EMIT evaluationSuccessful();
} else {
_context->accountBuilder().setWebFingerAuthenticationServerUrl(checkWebFingerAuthJob->result().toUrl());
Q_EMIT evaluationSuccessful();
}
});
Q_EMIT evaluationSuccessful();
});

connect(
Expand Down