mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 22:05:53 +03:00
DetermineAuth: Remove concept of Unknown #6148
This restores 2.3 behavior. Some servers reply 404 to GETs and PROPFINDs to the remote.php/webdav/ url and used to work. Being more picky would break them.
This commit is contained in:
parent
820ebf4b6e
commit
3ae2071129
4 changed files with 11 additions and 19 deletions
|
@ -46,15 +46,6 @@ void HttpCredentialsGui::askFromUserAsync()
|
||||||
// First, we will check what kind of auth we need.
|
// First, we will check what kind of auth we need.
|
||||||
auto job = new DetermineAuthTypeJob(_account->sharedFromThis(), this);
|
auto job = new DetermineAuthTypeJob(_account->sharedFromThis(), this);
|
||||||
QObject::connect(job, &DetermineAuthTypeJob::authType, this, [this](DetermineAuthTypeJob::AuthType type) {
|
QObject::connect(job, &DetermineAuthTypeJob::authType, this, [this](DetermineAuthTypeJob::AuthType type) {
|
||||||
if (type == DetermineAuthTypeJob::Unknown) {
|
|
||||||
// network error, timeout, unsupported auth type?
|
|
||||||
// This fallback exists for backwards compatibility reasons:
|
|
||||||
// in versions before 2.4 we tried basic auth when the auth type
|
|
||||||
// couldn't be determined.
|
|
||||||
qCWarning(lcHttpCredentialsGui) << "Could not determine auth type, falling back to Basic";
|
|
||||||
type = DetermineAuthTypeJob::Basic;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == DetermineAuthTypeJob::OAuth) {
|
if (type == DetermineAuthTypeJob::OAuth) {
|
||||||
_asyncAuth.reset(new OAuth(_account, this));
|
_asyncAuth.reset(new OAuth(_account, this));
|
||||||
_asyncAuth->_expectedUser = _user;
|
_asyncAuth->_expectedUser = _user;
|
||||||
|
@ -69,7 +60,7 @@ void HttpCredentialsGui::askFromUserAsync()
|
||||||
// We will re-enter the event loop, so better wait the next iteration
|
// We will re-enter the event loop, so better wait the next iteration
|
||||||
QMetaObject::invokeMethod(this, "showDialog", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "showDialog", Qt::QueuedConnection);
|
||||||
} else {
|
} else {
|
||||||
// Unsupported auth type? Shibboleth?
|
// Shibboleth?
|
||||||
qCWarning(lcHttpCredentialsGui) << "Bad http auth type:" << type;
|
qCWarning(lcHttpCredentialsGui) << "Bad http auth type:" << type;
|
||||||
emit asked();
|
emit asked();
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,13 +201,15 @@ bool OwncloudSetupPage::urlHasChanged()
|
||||||
|
|
||||||
int OwncloudSetupPage::nextId() const
|
int OwncloudSetupPage::nextId() const
|
||||||
{
|
{
|
||||||
if (_authType == DetermineAuthTypeJob::Basic) {
|
switch (_authType) {
|
||||||
|
case DetermineAuthTypeJob::Basic:
|
||||||
return WizardCommon::Page_HttpCreds;
|
return WizardCommon::Page_HttpCreds;
|
||||||
} else if (_authType == DetermineAuthTypeJob::OAuth) {
|
case DetermineAuthTypeJob::OAuth:
|
||||||
return WizardCommon::Page_OAuthCreds;
|
return WizardCommon::Page_OAuthCreds;
|
||||||
} else {
|
case DetermineAuthTypeJob::Shibboleth:
|
||||||
return WizardCommon::Page_ShibbolethCreds;
|
return WizardCommon::Page_ShibbolethCreds;
|
||||||
}
|
}
|
||||||
|
return WizardCommon::Page_HttpCreds;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OwncloudSetupPage::url() const
|
QString OwncloudSetupPage::url() const
|
||||||
|
|
|
@ -863,8 +863,8 @@ void DetermineAuthTypeJob::start()
|
||||||
auto authChallenge = reply->rawHeader("WWW-Authenticate").toLower();
|
auto authChallenge = reply->rawHeader("WWW-Authenticate").toLower();
|
||||||
if (authChallenge.contains("bearer ")) {
|
if (authChallenge.contains("bearer ")) {
|
||||||
_resultPropfind = OAuth;
|
_resultPropfind = OAuth;
|
||||||
} else if (!authChallenge.isEmpty()) {
|
} else if (authChallenge.isEmpty()) {
|
||||||
_resultPropfind = Basic;
|
qCWarning(lcDetermineAuthTypeJob) << "Did not receive WWW-Authenticate reply to auth-test PROPFIND";
|
||||||
}
|
}
|
||||||
_propfindDone = true;
|
_propfindDone = true;
|
||||||
checkBothDone();
|
checkBothDone();
|
||||||
|
|
|
@ -360,8 +360,7 @@ class OWNCLOUDSYNC_EXPORT DetermineAuthTypeJob : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum AuthType {
|
enum AuthType {
|
||||||
Unknown,
|
Basic, // also the catch-all fallback for backwards compatibility reasons
|
||||||
Basic,
|
|
||||||
OAuth,
|
OAuth,
|
||||||
Shibboleth
|
Shibboleth
|
||||||
};
|
};
|
||||||
|
@ -375,8 +374,8 @@ private:
|
||||||
void checkBothDone();
|
void checkBothDone();
|
||||||
|
|
||||||
AccountPtr _account;
|
AccountPtr _account;
|
||||||
AuthType _resultGet = Unknown;
|
AuthType _resultGet = Basic;
|
||||||
AuthType _resultPropfind = Unknown;
|
AuthType _resultPropfind = Basic;
|
||||||
bool _getDone = false;
|
bool _getDone = false;
|
||||||
bool _propfindDone = false;
|
bool _propfindDone = false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue