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

Remove dead OAuth code #6005

Merged
merged 1 commit into from
Sep 19, 2023
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
5 changes: 0 additions & 5 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ set(client_UI_SRCS
wizard/owncloudadvancedsetuppage.ui
wizard/owncloudconnectionmethoddialog.ui
wizard/owncloudhttpcredspage.ui
wizard/owncloudoauthcredspage.ui
wizard/owncloudsetupnocredspage.ui
wizard/webview.ui
wizard/welcomepage.ui
Expand Down Expand Up @@ -224,8 +223,6 @@ set(client_SRCS
creds/credentialsfactory.cpp
creds/httpcredentialsgui.h
creds/httpcredentialsgui.cpp
creds/oauth.h
creds/oauth.cpp
creds/flow2auth.h
creds/flow2auth.cpp
creds/webflowcredentials.h
Expand All @@ -242,8 +239,6 @@ set(client_SRCS
wizard/owncloudconnectionmethoddialog.cpp
wizard/owncloudhttpcredspage.h
wizard/owncloudhttpcredspage.cpp
wizard/owncloudoauthcredspage.h
wizard/owncloudoauthcredspage.cpp
wizard/flow2authcredspage.h
wizard/flow2authcredspage.cpp
wizard/flow2authwidget.h
Expand Down
14 changes: 1 addition & 13 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,19 +1271,7 @@ void AccountSettings::slotAccountStateChanged()
showConnectionLabel(tr("Signed out from %1.").arg(serverWithUser));
break;
case AccountState::AskingCredentials: {
QUrl url;
if (const auto cred = qobject_cast<HttpCredentialsGui *>(account->credentials())) {
connect(cred, &HttpCredentialsGui::authorisationLinkChanged,
this, &AccountSettings::slotAccountStateChanged, Qt::UniqueConnection);
url = cred->authorisationLink();
}
if (url.isValid()) {
showConnectionLabel(tr("Obtaining authorization from the browser. "
"<a href='%1'>Click here</a> to re-open the browser.")
.arg(url.toString(QUrl::FullyEncoded)));
} else {
showConnectionLabel(tr("Connecting to %1 …").arg(serverWithUser));
}
showConnectionLabel(tr("Connecting to %1 …").arg(serverWithUser));
break;
}
case AccountState::NetworkError:
Expand Down
4 changes: 0 additions & 4 deletions src/gui/accountstate.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/accountstate.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/accountstate.cpp

File src/gui/accountstate.cpp (lines 15, 27, 38, 53, 55, 57, 59, 61, 64, 113, 245, 294, 296, 302, 353, 354, 357, 363, 370, 371, 437, 442, 450, 460, 468, 476, 504, 518, 519, 535, 551, 552, 562, 563, 596, 602, 606, 610, 611, 628, 630, 645, 646): Code does not conform to Custom style guidelines.
* Copyright (C) by Daniel Molkentin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -456,10 +456,6 @@
if (account()->credentials()->ready()) {
account()->credentials()->invalidateToken();
}
if (auto creds = qobject_cast<HttpCredentials *>(account()->credentials())) {
if (creds->refreshAccessToken())
return;
}
account()->credentials()->askFromUser();
}

Expand Down
38 changes: 1 addition & 37 deletions src/gui/creds/httpcredentialsgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@ void HttpCredentialsGui::askFromUserAsync()
// First, we will check what kind of auth we need.
auto job = new DetermineAuthTypeJob(_account->sharedFromThis(), this);
QObject::connect(job, &DetermineAuthTypeJob::authType, this, [this](DetermineAuthTypeJob::AuthType type) {
if (type == DetermineAuthTypeJob::OAuth) {
_asyncAuth.reset(new OAuth(_account, this));
_asyncAuth->_expectedUser = _account->davUser();
connect(_asyncAuth.data(), &OAuth::result,
this, &HttpCredentialsGui::asyncAuthResult);
connect(_asyncAuth.data(), &OAuth::destroyed,
this, &HttpCredentialsGui::authorisationLinkChanged);
_asyncAuth->start();
emit authorisationLinkChanged();
} else if (type == DetermineAuthTypeJob::Basic) {
if (type == DetermineAuthTypeJob::Basic) {
showDialog();
} else {
// Shibboleth?
Expand All @@ -66,32 +57,6 @@ void HttpCredentialsGui::askFromUserAsync()
job->start();
}

void HttpCredentialsGui::asyncAuthResult(OAuth::Result r, const QString &user,
const QString &token, const QString &refreshToken)
{
switch (r) {
case OAuth::NotSupported:
showDialog();
_asyncAuth.reset(nullptr);
return;
case OAuth::Error:
_asyncAuth.reset(nullptr);
emit asked();
return;
case OAuth::LoggedIn:
break;
}

ASSERT(_user == user); // ensured by _asyncAuth

_password = token;
_refreshToken = refreshToken;
_ready = true;
persist();
_asyncAuth.reset(nullptr);
emit asked();
}

void HttpCredentialsGui::showDialog()
{
QString msg = tr("Please enter %1 password:<br>"
Expand Down Expand Up @@ -128,7 +93,6 @@ void HttpCredentialsGui::showDialog()
connect(dialog, &QDialog::finished, this, [this, dialog](int result) {
if (result == QDialog::Accepted) {
_password = dialog->textValue();
_refreshToken.clear();
_ready = true;
persist();
}
Expand Down
25 changes: 0 additions & 25 deletions src/gui/creds/httpcredentialsgui.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/creds/httpcredentialsgui.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/creds/httpcredentialsgui.h

File src/gui/creds/httpcredentialsgui.h (lines 21, 35): Code does not conform to Custom style guidelines.
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Olivier Goffart <[email protected]>
*
Expand All @@ -15,7 +15,6 @@

#pragma once
#include "creds/httpcredentials.h"
#include "creds/oauth.h"
#include <QPointer>
#include <QTcpServer>

Expand All @@ -38,37 +37,13 @@
: HttpCredentials(user, password, clientCertBundle, clientCertPassword)
{
}
HttpCredentialsGui(const QString &user, const QString &password, const QString &refreshToken,
const QByteArray &clientCertBundle, const QByteArray &clientCertPassword)
: HttpCredentials(user, password, clientCertBundle, clientCertPassword)
{
_refreshToken = refreshToken;
}

/**
* This will query the server and either uses OAuth via _asyncAuth->start()
* or call showDialog to ask the password
*/
void askFromUser() override;
/**
* In case of oauth, return an URL to the link to open the browser.
* An invalid URL otherwise
*/
[[nodiscard]] QUrl authorisationLink() const { return _asyncAuth ? _asyncAuth->authorisationLink() : QUrl(); }


static QString requestAppPasswordText(const Account *account);
private slots:
void asyncAuthResult(OAuth::Result, const QString &user, const QString &accessToken, const QString &refreshToken);
void showDialog();
void askFromUserAsync();

signals:
void authorisationLinkChanged();

private:

QScopedPointer<OAuth, QScopedPointerObjectDeleteLater<OAuth>> _asyncAuth;
};

} // namespace OCC
187 changes: 0 additions & 187 deletions src/gui/creds/oauth.cpp

This file was deleted.

Loading
Loading